Skip to content

hexital

hexital

Modules:

Name Description
PPO
PSAR
analysis
candlesticks
core
indicators
movement
patterns
utils

Classes:

Name Description
ADX

Average Directional Index - ADX

AO

Awesome Oscillator - AO

AROON

Aroon - AROON

ATR

Average True Range - ATR

Amorph

Amorph

BBANDS

Bollinger Bands - BBANDS

BandWidth

Bollinger BandWidth - BBB

CCI

Commodity Channel Index - CCI

CKSP

Chande Kroll Stop - CKSP

CMF

Chaikin Money Flow - CMF

CMO

Chande Momentum Oscillator - CMO

COPC

Coppock Curve - COPC

Candle
ChandelierExit

Chandelier Exit

ChildWhen

When a child indicator is calculated relative to its parent.

Counter

Counter

DEMA

Double Exponential Moving Average - DEMA

Donchian

Donchian Channels - Donchian

EMA

Exponential Moving Average - EMA

Fisher

Fisher Transform - FISHERT

HL

Highest Lowest - HL

HLA

High Low Average - HLA

HLCA

High Low Close Average - HLCA

HMA

Hull Moving Average - HMA

Hexital
Ichimoku

Ichimoku Kinko Hyo - ICHIMOKU

Indicator
IndicatorCollection

Group indicators for direct attribute access on a strategy collection.

JMA

Jurik Moving Average Average - JMA

KAMA

Kaufman's Adaptive Moving Average - KAMA

KC

Keltner Channel - KC

KST

Know Sure Thing - KST

LinearRegression

Linear Regression - LR

MACD

Moving Average Convergence Divergence - MACD

MFI

Money Flow Index - MFI

MOP

Midpoint Over Period - MOP

NATR

Normalized Average True Range - NATR

OBV

On-Balance Volume - OBC

PivotPoints

Pivot Points - PP

RMA

wildeR's Moving Average - RMA

ROC

Rate Of Change - ROC

RSI

Relative Strength Index - RSI

RVI

Relative Vigor Index - RVI

RegressionChannel

Regression Channel

RegressionSlope

Regression Slope - LRm

SMA

Simple Moving Average - SMA

STDEV

Rolling Standard Deviation - STDEV

STDEVT

Standard Deviation Threshold - STDEVT

STOCH

Stochastic - STOCH

Squeeze

Squeeze

SqueezePro

SqueezePro

State

Internal state backed by a managed child indicator.

Supertrend

Supertrend

TEMA

Triple Exponential Moving Average - TEMA

TR

True Range - TR

TRIX

Triple Exponential Average Oscillator - TRIX

TSI

True Strength Index - TSI

TimeFrame

Pre-defined TimeFrame values

UO

Ultimate Oscillator - UO

VWAP

Volume-Weighted Average Price - VWAP

VWMA

Volume Weighted Moving Average - VWMA

Vortex

Vortex Indicator - VTX

WMA

Weighted Moving Average - WMA

WillR

William's Percent R - WILLR

ZScore

Rolling Z Score - ZS

Functions:

Name Description
indicator_field

Mark a dataclass field as a strategy indicator for IndicatorCollection.

ADX dataclass

ADX(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    period_signal: int = 0,
    multiplier: float = 100.0
)

Bases: Indicator[dict[str, float | None]]

Average Directional Index - ADX

ADX is a trend strength in a series of prices of a financial instrument.

Sources

https://en.wikipedia.org/wiki/Average_directional_movement_index

Output type: Dict["ADX": float, "DM_Plus": float, "DM_Neg": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14
period_signal Optional[int]

Average Directional Index period. Defaults same as period

0
multiplier float | None

ADX smoothing multiplier. Defaults to 100.0

100.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

AO dataclass

AO(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    fast: int = 5,
    slow: int = 34
)

Bases: Indicator[float | None]

Awesome Oscillator - AO

Awesome Oscillator compares a fast and slow simple moving average of the median price.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/momentum/help/pandas_ta.momentum.ao.html

Output type: float

Parameters:

Name Type Description Default
fast int

Fast SMA length. Defaults to 5.

5
slow int

Slow SMA length. Defaults to 34.

34

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

AROON dataclass

AROON(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14
)

Bases: Indicator[dict[str, float | None]]

Aroon - AROON

The Aroon indicator, indicates if a price is trending or is in a trading range. It can also reveal the beginning of a new trend, its strength and can help anticipate changes from trading ranges to trends.

Sources

https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/aroon-indicator

Output type: Dict["AROONU": float, "AROOND": float, "AROONOSC": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

ATR dataclass

ATR(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14
)

Bases: Indicator[float | None]

Average True Range - ATR

Average True Range is used to measure volatility, especially volatility caused by gaps or limit moves.

Sources

https://www.tradingview.com/wiki/Average_True_Range_(ATR)

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Amorph

Amorph(analysis: Callable, args: dict | None = None, **kwargs)

Bases: Indicator

Amorph

Flexible Skeleton Indicator that will use a method to generate readings on every Candle like indicators.

The given Method is expected to have 'candles' and 'index' as named arguments, EG:

Input type Example: Doji

Output type: Based on analysis method

Parameters:

Name Type Description Default
analysis Callable

Period to index back in

required
args dict | None

All of the Arguments as keyword arguments as a dict of keyword arguments for called analysis

None

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Returns a dict format of how this indicator can be generated

Source code in hexital/indicators/amorph.py
def __init__(self, analysis: Callable, args: dict | None = None, **kwargs):
    self._analysis_method = analysis
    self.analysis_name = analysis.__name__
    self._analysis_kwargs, kwargs = self._separate_indicator_attributes(kwargs)

    if isinstance(args, dict):
        self._analysis_kwargs.update(args)

    super().__init__(**kwargs)

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Returns a dict format of how this indicator can be generated

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

BBANDS dataclass

BBANDS(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 5,
    source: Source = "close",
    std: float = 2.0
)

Bases: Indicator[dict[str, float | None]]

Bollinger Bands - BBANDS

Bollinger Bands are a type of statistical chart characterizing the prices and volatility over time of a financial instrument or commodity, using a formulaic method.

Sources

https://www.britannica.com/money/bollinger-bands-indicator

Output type: Dict["BBL": float, "BBM": float, "BBU": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 5

5
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

BandWidth dataclass

BandWidth(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 5,
    source: Source = "close",
    std: float = 2.0
)

Bases: Indicator[float | None]

Bollinger BandWidth - BBB

BandWidth expresses the Bollinger Band spread relative to the middle band.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/volatility/help/pandas_ta.volatility.bbands.html

Output type: float

Parameters:

Name Type Description Default
period int

How many periods to use. Defaults to 5.

5
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'
std float

Standard deviation multiplier. Defaults to 2.0.

2.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

CCI dataclass

CCI(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close",
    scaling: float = 0.015
)

Bases: Indicator[float | None]

Commodity Channel Index - CCI

The Commodity Channel Index measures the current typical price relative to its rolling mean and mean absolute deviation over a fixed lookback period. It is commonly used to identify overbought, oversold, and trend deviation conditions.

Output type: float

Parameters:

Name Type Description Default
period int

How many periods to use. Defaults to 14

14
source str

Which input field to calculate the indicator from. Defaults to "close"

'close'
c float

Constant scaling factor applied to the mean absolute deviation. Defaults to 0.015

required

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

CKSP dataclass

CKSP(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    multiplier: float = 3.0,
    smooth_period: int = 20,
    tvmode: bool = True
)

Bases: Indicator[dict[str, float | None]]

Chande Kroll Stop - CKSP

CKSP builds trailing stop bands from ATR and then smooths those raw stop levels with rolling extrema.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/trend/help/pandas_ta.trend.cksp.html

Output type: Dict["long": float, "short": float]

Parameters:

Name Type Description Default
period int

ATR and primary stop lookback. Defaults to 10. pandas_ta alias: p

10
multiplier float

ATR multiplier. Defaults to 3.0. pandas_ta alias: x

3.0
smooth_period int

Secondary smoothing lookback. Defaults to 20. pandas_ta alias: q

20
tvmode bool

Use TradingView ATR smoothing mode. Defaults to True.

True

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

CMF dataclass

CMF(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 20
)

Bases: Indicator[float | None]

Chaikin Money Flow - CMF

Chaikin Money Flow measures buying and selling pressure by comparing rolling money flow volume against rolling total volume.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/volume/help/pandas_ta.volume.cmf.html

Output type: float

Parameters:

Name Type Description Default
period int

Rolling window length. Defaults to 20.

20

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

CMO dataclass

CMO(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close"
)

Bases: Indicator[float | None]

Chande Momentum Oscillator - CMO

The CMO indicator is created by calculating the difference between the sum of all recent higher closes and the sum of all recent lower closes and then dividing the result by the sum of all price movement over a given time period. The result is multiplied by 100 to give the -100 to +100 range.

Sources

https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/cmo

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

COPC dataclass

COPC(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    fast: int = 11,
    slow: int = 14
)

Bases: Indicator[float | None]

Coppock Curve - COPC

Coppock Curve is a weighted moving average of the sum of two rate-of-change series.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/momentum/help/pandas_ta.momentum.coppock.html

Output type: float

Parameters:

Name Type Description Default
period int

WMA smoothing length. Defaults to 10.

10
fast int

Fast ROC length. Defaults to 11.

11
slow int

Slow ROC length. Defaults to 14.

14

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Candle

Candle(
    open: float,
    high: float,
    low: float,
    close: float,
    volume: int,
    timestamp: datetime | str | None = None,
    timeframe: TimeFramesSource | None = None,
    indicators: dict[str, Reading] | None = None,
    sub_indicators: dict[str, Reading] | None = None,
    aggregation_factor: int | None = None,
)

Methods:

Name Description
admit_for_storage

Return a candle safe to store in a CandleManager.

as_dict

Generates a dict of values from the OHLCV values, with the following keys:

as_list

Generates a list of values from the OHLCV values.

clean_copy

Create a clean copy with OHLCV data but without indicators, refs, or tag.

from_dict

Create a Candle object from a dictionary representation.

from_dicts

Create's a list of Candle object's from a list of dictionary representation.

from_list

Create a Candle object from a list representation.

from_lists

Create a list of Candle object's from a list of list representation.

merge

Merge another Candle object into the current candle.

Attributes:

Name Type Description
is_clean bool

True when the candle has no readings, refs, or tag attached.

Source code in hexital/core/candle.py
def __init__(
    self,
    open: float,
    high: float,
    low: float,
    close: float,
    volume: int,
    timestamp: datetime | str | None = None,  # End of Candle
    timeframe: TimeFramesSource | None = None,
    indicators: dict[str, Reading] | None = None,
    sub_indicators: dict[str, Reading] | None = None,
    aggregation_factor: int | None = None,
):
    self.open = open
    self.high = high
    self.low = low
    self.close = close
    self.volume = volume
    self.timeframe = convert_timeframe_to_timedelta(timeframe) if timeframe else None

    self.tag = None
    self.aggregation_factor = (
        aggregation_factor if aggregation_factor is not None else 1
    )

    if isinstance(timestamp, datetime):
        self.timestamp = timestamp
    elif isinstance(timestamp, str):
        self.timestamp = datetime.fromisoformat(timestamp)
    else:
        self.timestamp = None

    self.refs = {}
    self.indicators = indicators if indicators else {}
    self.sub_indicators = sub_indicators if sub_indicators else {}

is_clean property

is_clean: bool

True when the candle has no readings, refs, or tag attached.

admit_for_storage

admit_for_storage(
    admitted: set[int] | None = None, *, force_copy: bool = False
) -> Candle

Return a candle safe to store in a CandleManager.

Source code in hexital/core/candle.py
def admit_for_storage(
    self, admitted: set[int] | None = None, *, force_copy: bool = False
) -> Candle:
    """Return a candle safe to store in a CandleManager."""
    if force_copy or not self.is_clean:
        return self.clean_copy()
    if admitted is None:
        return self
    key = id(self)
    if key in admitted:
        return self.clean_copy()
    admitted.add(key)
    return self

as_dict

as_dict(readings: bool = False) -> dict

Generates a dict of values from the OHLCV values, with the following keys: [timestamp, open, high, low, close, volume]

Parameters:

Name Type Description Default
readings bool

Include Candle readings

False

Returns:

Name Type Description
dict dict

A list of the Candle values

dict

{open, high, low, close, volume, timestamp, timeframe*}

dict

{open, high, low, close, volume, timestamp, indicators, sub_indicators, timeframe*}

Source code in hexital/core/candle.py
def as_dict(self, readings: bool = False) -> dict:
    """
    Generates a dict of values from the OHLCV values, with  the following keys:
    `[timestamp, open, high, low, close, volume]`

    Args:
        readings (bool): Include Candle readings

    Returns:
        dict: A list of the `Candle` values
        {open, high, low, close, volume, timestamp, timeframe*}
        {open, high, low, close, volume, timestamp, indicators, sub_indicators, timeframe*}
    """
    cdl = {
        "open": self.open,
        "high": self.high,
        "low": self.low,
        "close": self.close,
        "volume": self.volume,
        "timestamp": self.timestamp,
    }

    if self.timeframe:
        cdl["timeframe"] = self.timeframe

    if readings:
        cdl["indicators"] = self.indicators
        cdl["sub_indicators"] = self.sub_indicators

    return cdl

as_list

as_list(readings: bool = False) -> list

Generates a list of values from the OHLCV values. [timestamp, open, high, low, close, volume] in that order. With an optional timedelta value at the end being the timeframe

Parameters:

Name Type Description Default
readings bool

Include Candle readings

False

Returns:

Name Type Description
list list

A list of the Candle values;

list

[timestamp, open, high, low, close, volume, timeframe*]

list

[timestamp, open, high, low, close, volume, indicators, sub_indicators, timeframe*]

Source code in hexital/core/candle.py
def as_list(self, readings: bool = False) -> list:
    """
    Generates a list of values from the OHLCV values.
    `[timestamp, open, high, low, close, volume]` in that order.
    With an optional `timedelta` value at the end being the `timeframe`

    Args:
        readings (bool): Include Candle readings

    Returns:
        list: A list of the `Candle` values;
        [timestamp, open, high, low, close, volume, timeframe*]
        [timestamp, open, high, low, close, volume, indicators, sub_indicators, timeframe*]
    """
    cdl = [self.timestamp, self.open, self.high, self.low, self.close, self.volume]

    if readings:
        cdl.append(self.indicators)
        cdl.append(self.sub_indicators)

    cdl += [self.timeframe] if self.timeframe else []

    return cdl

clean_copy

clean_copy() -> Candle

Create a clean copy with OHLCV data but without indicators, refs, or tag.

Source code in hexital/core/candle.py
def clean_copy(self) -> Candle:
    """Create a clean copy with OHLCV data but without indicators, refs, or tag."""
    return Candle(
        open=self.open,
        high=self.high,
        low=self.low,
        close=self.close,
        volume=self.volume,
        timestamp=self.timestamp,
        timeframe=self.timeframe,
        aggregation_factor=self.aggregation_factor,
    )

from_dict classmethod

from_dict(
    candle: dict[str, Any], timeframe: TimeFramesSource | None = None
) -> Candle

Create a Candle object from a dictionary representation.

The dictionary is expected to have the following keys: - Required: 'open', 'high', 'low', 'close', 'volume' - Optional: 'timestamp' | 'time' | 'date' - Optional: 'timeframe', 'indicators', 'sub_indicators'

The method extracts the values for these keys. If the optional keys for time ('timestamp', 'time', etc.) are present, the first match is used as the timestamp.

Parameters:

Name Type Description Default
candle Dict[str, Any]

A dictionary containing the candle data.

required
timeframe TimeFramesSource | None

Optional fallback timeframe used when the dictionary does not contain a timeframe field.

None

Returns:

Name Type Description
Candle Candle

A Candle object initialized with the provided dictionary data.

Source code in hexital/core/candle.py
@classmethod
def from_dict(
    cls,
    candle: dict[str, Any],
    timeframe: TimeFramesSource | None = None,
) -> Candle:
    """
    Create a `Candle` object from a dictionary representation.

    The dictionary is expected to have the following keys:
    - Required: 'open', 'high', 'low', 'close', 'volume'
    - Optional: 'timestamp' | 'time' | 'date'
    - Optional: 'timeframe', 'indicators', 'sub_indicators'

    The method extracts the values for these keys. If the optional keys for time ('timestamp',
    'time', etc.) are present, the first match is used as the timestamp.

    Args:
        candle (Dict[str, Any]): A dictionary containing the candle data.
        timeframe: Optional fallback timeframe used when the dictionary does
            not contain a timeframe field.

    Returns:
        Candle: A `Candle` object initialized with the provided dictionary data.
    """
    timestamp = [
        v
        for k, v in candle.items()
        if k in ["timestamp", "Timestamp", "time", "Time", "date", "Date"]
    ]

    if timestamp and not isinstance(timestamp[0], (datetime, str)):
        raise TypeError("Timestamp must be native python Datetime object")

    candle_timeframe = candle.get("timeframe", candle.get("Timeframe", timeframe))

    return cls(
        candle.get("open", candle.get("Open", 0.0)),
        candle.get("high", candle.get("High", 0.0)),
        candle.get("low", candle.get("Low", 0.0)),
        candle.get("close", candle.get("Close", 0.0)),
        candle.get("volume", candle.get("Volume", 0)),
        indicators=candle.get("indicators", {}),
        sub_indicators=candle.get("sub_indicators", {}),
        timestamp=timestamp[0] if timestamp else None,
        timeframe=candle_timeframe,
    )

from_dicts classmethod

from_dicts(
    candles: Sequence[dict[str, Any]], timeframe: TimeFramesSource | None = None
) -> list[Candle]

Create's a list of Candle object's from a list of dictionary representation.

Each dictionary is expected to have the following keys: - Required: 'open', 'high', 'low', 'close', 'volume' - Optional: 'timestamp' | 'time' | 'date' - Optional: 'timeframe', 'indicators', 'sub_indicators'

The method extracts the values for these keys. If the optional keys for time ('timestamp', 'time', etc.) are present, the first match is used as the timestamp. Returning a list of Candle objects initialized with the provided dictionary data.

Parameters:

Name Type Description Default
candles List[Dict[str, Any]]

A dictionary containing the candle data.

required
timeframe TimeFramesSource | None

Optional fallback timeframe used when an item does not contain a timeframe field.

None

Returns:

Type Description
list[Candle]

List[Candle]: A list of Candle object's.

Source code in hexital/core/candle.py
@classmethod
def from_dicts(
    cls,
    candles: Sequence[dict[str, Any]],
    timeframe: TimeFramesSource | None = None,
) -> list[Candle]:
    """
    Create's a list of `Candle` object's from a list of dictionary representation.

    Each dictionary is expected to have the following keys:
    - Required: 'open', 'high', 'low', 'close', 'volume'
    - Optional: 'timestamp' | 'time' | 'date'
    - Optional: 'timeframe', 'indicators', 'sub_indicators'

    The method extracts the values for these keys. If the optional keys for time ('timestamp',
    'time', etc.) are present, the first match is used as the timestamp.
    Returning a list of `Candle` objects initialized with the provided dictionary data.

    Args:
        candles (List[Dict[str, Any]]): A dictionary containing the candle data.
        timeframe: Optional fallback timeframe used when an item does not
            contain a timeframe field.

    Returns:
        List[Candle]: A list of `Candle` object's.
    """
    return [cls.from_dict(candle, timeframe=timeframe) for candle in candles]

from_list classmethod

from_list(candle: list, timeframe: TimeFramesSource | None = None) -> Candle

Create a Candle object from a list representation.

The list is expected to contain the following elements: - Required: [open, high, low, close, volume] in that order. - Optional: A timestamp at the beginning of the list. - Optional: A timeframe at the end of the list. - Optional: Dict's indicators, sub_indicators after Volume.

If the first element is a str or datetime, it is treated as the timestamp. If the last element is a str, int, TimeFrame, or timedelta, it is treated as the timeframe.

Parameters:

Name Type Description Default
candle list

A list containing the candle data.

required
timeframe TimeFramesSource | None

Optional fallback timeframe used when the list does not contain a timeframe value.

None

Returns:

Name Type Description
Candle Candle

A Candle object initialized with the data from the list.

Source code in hexital/core/candle.py
@classmethod
def from_list(
    cls,
    candle: list,
    timeframe: TimeFramesSource | None = None,
) -> Candle:
    """
    Create a `Candle` object from a list representation.

    The list is expected to contain the following elements:
    - Required: `[open, high, low, close, volume]` in that order.
    - Optional: A `timestamp` at the beginning of the list.
    - Optional: A `timeframe` at the end of the list.
    - Optional: Dict's `indicators`, `sub_indicators` after Volume.

    If the first element is a `str` or `datetime`, it is treated as the `timestamp`.
    If the last element is a `str`, `int`, `TimeFrame`, or `timedelta`, it is treated as the `timeframe`.

    Args:
        candle (list): A list containing the candle data.
        timeframe: Optional fallback timeframe used when the list does not
            contain a timeframe value.

    Returns:
        Candle: A `Candle` object initialized with the data from the list.
    """
    candle = list(candle)
    timestamp = None
    candle_timeframe = timeframe
    indicators = {}
    sub_indicators = {}

    if len(candle) > 5 and (
        isinstance(candle[0], (str, datetime)) or candle[0] is None
    ):
        timestamp = candle.pop(0)
    if len(candle) > 5 and isinstance(candle[-1], TimeFramesSource):
        candle_timeframe = candle.pop(-1)
    if (
        len(candle) > 5
        and isinstance(candle[-1], dict)
        and isinstance(candle[-2], dict)
    ):
        sub_indicators = candle.pop(-1)
        indicators = candle.pop(-1)

    return cls(
        open=candle[0],  # type: ignore
        high=candle[1],
        low=candle[2],
        close=candle[3],
        volume=candle[4],
        indicators=indicators,
        sub_indicators=sub_indicators,
        timestamp=timestamp,
        timeframe=candle_timeframe,
    )

from_lists classmethod

from_lists(
    candles: list[list], timeframe: TimeFramesSource | None = None
) -> list[Candle]

Create a list of Candle object's from a list of list representation.

Each list is expected to contain the following elements: - Required: [open, high, low, close, volume] in that order. - Optional: A timestamp at the beginning of the list. - Optional: A timeframe at the end of the list. - Optional: Dict's indicators, sub_indicators after Volume.

If the first element is a str or datetime, it is treated as the timestamp. If the last element is a str, int, TimeFrame, or timedelta, it is treated as the timeframe.

Parameters:

Name Type Description Default
candles List[list]

A list of list's containing the candle data.

required
timeframe TimeFramesSource | None

Optional fallback timeframe used when an item does not contain a timeframe value.

None

Returns:

Type Description
list[Candle]

List[Candle]: A list of Candle object's.

Source code in hexital/core/candle.py
@classmethod
def from_lists(
    cls,
    candles: list[list],
    timeframe: TimeFramesSource | None = None,
) -> list[Candle]:
    """
    Create a list of `Candle` object's from a list of list representation.

    Each list is expected to contain the following elements:
    - Required: `[open, high, low, close, volume]` in that order.
    - Optional: A `timestamp` at the beginning of the list.
    - Optional: A `timeframe` at the end of the list.
    - Optional: Dict's `indicators`, `sub_indicators` after Volume.

    If the first element is a `str` or `datetime`, it is treated as the `timestamp`.
    If the last element is a `str`, `int`, `TimeFrame`, or `timedelta`, it is treated as the `timeframe`.

    Args:
        candles (List[list]): A list of list's containing the candle data.
        timeframe: Optional fallback timeframe used when an item does not
            contain a timeframe value.

    Returns:
        List[Candle]: A list of `Candle` object's.
    """
    return [cls.from_list(candle, timeframe=timeframe) for candle in candles]

merge

merge(candle: Candle)

Merge another Candle object into the current candle.

This method updates the current candle by integrating data from the provided candle. It ensures that the merged values respect the timeframe boundaries and adjusts attributes such as open, high, low, close, volume, and timestamps accordingly.

Note: - Any calculated indicators will be wiped, as merging modifies the core candle values. - Any conversion or derived values associated with the candle will also be removed.

Parameters:

Name Type Description Default
candle Candle

The Candle object to merge into the current candle.

required
Behaviour
  • Adjusts the open if the merged candle's timestamp is earlier than the start timestamp.
  • Updates the close if the merged candle's timestamp is more recent.
  • Updates high and low based on the maximum and minimum values of the two candles.
  • Increases the volume by the volume of the merged candle.
  • Increments the aggregation_factor to account for the merged data.
  • Resets calculated indicators and cleans any derived values.
Source code in hexital/core/candle.py
def merge(self, candle: Candle):
    """
    Merge another `Candle` object into the current candle.

    This method updates the current candle by integrating data from the provided `candle`.
    It ensures that the merged values respect the timeframe boundaries and adjusts
    attributes such as open, high, low, close, volume, and timestamps accordingly.

    **Note:**
    - Any calculated indicators will be wiped, as merging modifies the core candle values.
    - Any conversion or derived values associated with the candle will also be removed.

    Args:
        candle (Candle): The `Candle` object to merge into the current candle.

    Behaviour:
        - Adjusts the `open` if the merged candle's timestamp is earlier than the start timestamp.
        - Updates the `close` if the merged candle's timestamp is more recent.
        - Updates `high` and `low` based on the maximum and minimum values of the two candles.
        - Increases the `volume` by the volume of the merged candle.
        - Increments the `aggregation_factor` to account for the merged data.
        - Resets calculated indicators and cleans any derived values.
    """
    if self.timestamp is None or candle.timestamp is None:
        self.high = max(self.high, candle.high)
        self.low = min(self.low, candle.low)
        self.close = candle.close
        return

    if self.timeframe and (
        (candle.timestamp + self.timeframe > self.timestamp + self.timeframe)
        or (candle.timestamp < self.timestamp - self.timeframe)
    ):
        return

    if self._start_timestamp and candle.timestamp < self._start_timestamp:
        self.open = candle.open
        if not self._end_timestamp:
            self._end_timestamp = self._start_timestamp
        self._start_timestamp = candle.timestamp
    elif (
        self._start_timestamp
        and not self._end_timestamp
        and candle.timestamp > self._start_timestamp
    ) or (
        self._start_timestamp
        and self._end_timestamp
        and candle.timestamp > self._end_timestamp
    ):
        self.close = candle.close
        self._end_timestamp = candle.timestamp
    elif (
        self._start_timestamp
        and self._end_timestamp
        and self._start_timestamp > candle.timestamp > self._end_timestamp
    ):
        pass
    else:
        self.close = candle.close

    self.high = max(self.high, candle.high)
    self.low = min(self.low, candle.low)
    self.volume += candle.volume
    self.aggregation_factor += candle.aggregation_factor

    self.reset_candle()

ChandelierExit dataclass

ChandelierExit(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 22,
    multiplier: float = 3.0
)

Bases: Indicator[dict[str, float | None]]

Chandelier Exit

Chandelier Exit places trailing stop levels below the rolling high and above the rolling low using an ATR multiple.

Sources

https://chartschool.stockcharts.com/table-of-contents/technical-indicators-and-overlays/technical-overlays/chandelier-exit

Output type: Dict["long": float, "short": float]

Parameters:

Name Type Description Default
period int

Lookback and ATR period. Defaults to 22.

22
multiplier float

ATR multiple. Defaults to 3.0.

3.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

ChildWhen

Bases: str, Enum

When a child indicator is calculated relative to its parent.

Counter dataclass

Counter(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    source: Source,
    count_value: Any = True
)

Bases: Indicator[int]

Counter

Simple Indictor which will count the current streak of a given value, specifically designed for bool values, but useable on any other re-occurring values. E.G Count the streak for current input value == count_value

Output type: float

Parameters:

Name Type Description Default
source str

Which input field to calculate the Indicator.

required
count_value bool | int

Which value to be counting, E.G bool, 1, etc

True

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

DEMA dataclass

DEMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close"
)

Bases: Indicator[float | None]

Double Exponential Moving Average - DEMA

DEMA reduces lag versus a standard EMA by combining an EMA with an EMA of that EMA.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/overlap/help/pandas_ta.overlap.dema.html

Output type: float

Parameters:

Name Type Description Default
period int

How many periods to use. Defaults to 10.

10
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Donchian dataclass

Donchian(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 20
)

Bases: Indicator[dict[str, float | None]]

Donchian Channels - Donchian

Donchian Channels are a technical indicator that seeks to identify bullish and bearish extremes that favor reversals, higher and lower breakouts, breakdowns, and other emerging trends.

Sources

https://upstox.com/learning-center/share-market/a-comprehensive-guide-to-donchian-channels-formula-calculation-and-strategic-uses/ https://en.wikipedia.org/wiki/Donchian_channel

Output type: Dict["DCL": float, "DCM": float, "DCU": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 20

20

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

EMA dataclass

EMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close",
    smoothing: float = 2.0
)

Bases: Indicator[float | None]

Exponential Moving Average - EMA

The Exponential Moving Average is more responsive moving average compared to the Simple Moving Average (SMA). The weights are determined by alpha which is proportional to it's length.

Sources

https://www.investopedia.com/ask/answers/122314/what-exponential-moving-average-ema-formula-and-how-ema-calculated.asp

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'
smoothing float

Smoothing multiplier for EMA. Defaults to 2.0

2.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Fisher dataclass

Fisher(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 9,
    signal_period: int = 1
)

Bases: Indicator[dict[str, float | None]]

Fisher Transform - FISHERT

Fisher Transform converts price position inside a rolling range into a Gaussian-like oscillator with a lagged signal line.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/momentum/help/pandas_ta.momentum.fisher.html

Output type: Dict["FISHERT": float, "signal": float]

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

HL dataclass

HL(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 100
)

Bases: Indicator[dict[str, float | None]]

Highest Lowest - HL

Simple utility indicator to record and display the highest and lowest values N periods back.

Output type: Dict["low": float, "high": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 100

100

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

HLA dataclass

HLA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4
)

Bases: Indicator[float]

High Low Average - HLA

Output type: float

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

HLCA dataclass

HLCA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4
)

Bases: Indicator[float]

High Low Close Average - HLCA

Output type: float

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

HMA dataclass

HMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close"
)

Bases: Indicator[float | None]

Hull Moving Average - HMA

It is a combination of weighted moving averages designed to be more responsive to current price fluctuations while still smoothing prices.

Sources

https://school.stockcharts.com/doku.php?id=technical_indicators:hull_moving_average

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Hexital

Hexital(
    name: str,
    candles: Sequence[Candle],
    indicators: (
        Sequence[dict[str, Any] | Indicator] | IndicatorCollection | None
    ) = None,
    description: str | None = None,
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
)

Methods:

Name Description
add_indicator

Add's a new indicator to Hexital strategy.

all_series

Returns a Dictionary of all the Indicators and there results in a list format.

append

append a Candle or a chronological ordered list of Candle's to the end of the Hexital Candle's. This wil only re-sample and re-calculate the new Candles, with minor overlap.

calculate

Calculates all the missing indicator readings.

calculate_index

Calculate specific index for all or specific indicator readings.

candle_pair

Return candle streams for comparing two series on this strategy.

candles

Get a set of candles by using either a Timeframe or Indicator name

candles_for

Return the candle stream for an indicator, timeframe, or OHLCV field.

exists

Checks if the given Indicator has a valid reading in latest Candle

from_settings

Reconstruct a strategy from a settings dictionary.

indicator

Searches hexital's indicator's and Returns the Indicator object itself.

insert

insert a Candle or a list of Candle's to the Hexital Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Hexital Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

purge

Takes Indicator name and removes all readings for said indicator.

reading

Attempts to retrieve a reading with a given Indicator name.

recalculate

Purge's all indicator reading's and re-calculates them all,

remove_indicator

Removes an indicator from running within hexital

series

Find given indicator and returns the readings as a list

Source code in hexital/core/hexital.py
def __init__(
    self,
    name: str,
    candles: Sequence[Candle],
    indicators: Sequence[dict[str, Any] | Indicator]
    | IndicatorCollection
    | None = None,
    description: str | None = None,
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
):
    self.name = name
    self.description = description

    self._timeframe = convert_timeframe_to_timedelta(timeframe)
    self.timeframe_fill = timeframe_fill
    self.candle_life = candle_life

    self.candlestick = (
        validate_candlesticktype(candlestick) if candlestick else None
    )

    manager = CandleManager(
        list(candles),
        candle_life=self.candle_life,
        timeframe=self._timeframe,
        timeframe_fill=self.timeframe_fill,
        candlestick=self.candlestick,
    )
    self._candle_managers = [manager]

    self._indicators = {}
    if isinstance(indicators, IndicatorCollection):
        self._validate_indicators(indicators.collection_list())
    else:
        self._validate_indicators(indicators)

add_indicator

add_indicator(
    indicator: Indicator | list[Indicator | dict[str, Any]] | dict[str, Any]
)

Add's a new indicator to Hexital strategy. This accept either Indicator datatypes or dict string versions to be packed. add_indicator(SMA(period=10)) or add_indicator({"indicator": "SMA", "period": 10}) Does not automatically calculates readings.

Source code in hexital/core/hexital.py
def add_indicator(
    self, indicator: Indicator | list[Indicator | dict[str, Any]] | dict[str, Any]
):
    """Add's a new indicator to `Hexital` strategy.
    This accept either `Indicator` datatypes or dict string versions to be packed.
    `add_indicator(SMA(period=10))` or `add_indicator({"indicator": "SMA", "period": 10})`
    Does not automatically calculates readings."""
    indicators = indicator if isinstance(indicator, list) else [indicator]

    self._validate_indicators(indicators)

all_series

all_series() -> dict[str, list[Reading]]

Returns a Dictionary of all the Indicators and there results in a list format.

Source code in hexital/core/hexital.py
def all_series(self) -> dict[str, list[Reading]]:
    """Returns a Dictionary of all the Indicators and there results in a list format."""
    return {
        name: indicator.series() for name, indicator in self._indicators.items()
    }

append

append(candles: Candles)

append a Candle or a chronological ordered list of Candle's to the end of the Hexital Candle's. This wil only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to appended.

required
Source code in hexital/core/hexital.py
def append(self, candles: Candles):
    """append a Candle or a chronological ordered list of Candle's to the end of the Hexital Candle's. This wil only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to appended.
    """
    candles_ = parse_candles(candles)
    admitted = set()
    for candle_manager in self._candle_managers:
        candle_manager._append_parsed(candles_, admitted=admitted)

    self.calculate()

calculate

calculate(name: str | None = None)

Calculates all the missing indicator readings.

Source code in hexital/core/hexital.py
def calculate(self, name: str | None = None):
    """Calculates all the missing indicator readings."""
    if name is not None:
        if indicator := self._indicators.get(name):
            indicator.calculate()
    else:
        for indicator in self._indicators.values():
            indicator.calculate()

calculate_index

calculate_index(
    name: str | None = None, index: int = -1, end_index: int | None = None
)

Calculate specific index for all or specific indicator readings.

Source code in hexital/core/hexital.py
def calculate_index(
    self, name: str | None = None, index: int = -1, end_index: int | None = None
):
    """Calculate specific index for all or specific indicator readings."""
    if name is not None:
        if indicator := self._indicators.get(name):
            indicator.calculate_index(index, end_index)
    else:
        for indicator in self._indicators.values():
            indicator.calculate_index(index, end_index)

candle_pair

candle_pair(
    indicator: str, indicator_cmp: str
) -> tuple[list[Candle], list[Candle]]

Return candle streams for comparing two series on this strategy.

Source code in hexital/core/hexital.py
def candle_pair(
    self, indicator: str, indicator_cmp: str
) -> tuple[list[Candle], list[Candle]]:
    """Return candle streams for comparing two series on this strategy."""
    if indicator_cmp in ({"open", "high", "low", "close", "volume"}):
        stream = self.candles_for(indicator)
        return stream, stream
    if indicator in ({"open", "high", "low", "close", "volume"}):
        stream = self.candles_for(indicator_cmp)
        return stream, stream

    return self.candles_for(indicator), self.candles_for(indicator_cmp)

candles

candles(name: TimeFramesSource | None = None) -> list[Candle]

Get a set of candles by using either a Timeframe or Indicator name

Source code in hexital/core/hexital.py
def candles(self, name: TimeFramesSource | None = None) -> list[Candle]:
    """Get a set of candles by using either a Timeframe or Indicator name"""
    name_ = name if name else self._candle_managers[0].name
    timeframe_name = convert_timeframe_to_str(name)

    name_ = timeframe_name if timeframe_name else name_

    if isinstance(name_, str):
        if manager := next(
            (m for m in self._candle_managers if m.name == name_), None
        ):
            return manager.candles
        for manager in self._candle_managers:
            if manager.find_indicator(name_):
                return manager.candles

    return []

candles_for

candles_for(name: str) -> list[Candle]

Return the candle stream for an indicator, timeframe, or OHLCV field.

Source code in hexital/core/hexital.py
def candles_for(self, name: str) -> list[Candle]:
    """Return the candle stream for an indicator, timeframe, or OHLCV field."""
    if name in ({"open", "high", "low", "close", "volume"}):
        return self._candle_managers[0].candles
    return self.candles(name)

exists

exists(name: str) -> bool

Checks if the given Indicator has a valid reading in latest Candle

Source code in hexital/core/hexital.py
def exists(self, name: str) -> bool:
    """Checks if the given Indicator has a valid reading in latest Candle"""
    value = self.reading(name)
    if isinstance(value, dict):
        return any(v is not None for v in value.values())
    return value is not None

from_settings classmethod

from_settings(
    settings: dict[str, Any], candles: Sequence[Candle] | None = None
) -> Hexital

Reconstruct a strategy from a settings dictionary.

Source code in hexital/core/hexital.py
@classmethod
def from_settings(
    cls,
    settings: dict[str, Any],
    candles: Sequence[Candle] | None = None,
) -> Hexital:
    """Reconstruct a strategy from a settings dictionary."""
    config = decode_settings(copy(settings))

    try:
        name = config.pop("name")
    except KeyError as exc:
        raise InvalidIndicator("Strategy settings missing required 'name'") from exc

    if candles is None:
        candles = config.pop("candles", [])
    else:
        config.pop("candles", None)

    indicators = config.pop("indicators", None)
    return cls(name, list(candles), indicators=indicators, **config)

indicator

indicator(name: str) -> Indicator | None

Searches hexital's indicator's and Returns the Indicator object itself.

Source code in hexital/core/hexital.py
def indicator(self, name: str) -> Indicator | None:
    """Searches hexital's indicator's and Returns the Indicator object itself."""
    return self._indicators.get(name)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Hexital Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to inserted.

required
Source code in hexital/core/hexital.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Hexital Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to inserted.
    """
    candles_ = parse_candles(candles)
    admitted = set()
    for candle_manager in self._candle_managers:
        candle_manager._insert_parsed(candles_, admitted=admitted)

    self.calculate_index(index=0, end_index=-1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Hexital Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/hexital.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Hexital Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    candles_ = parse_candles(candles)
    admitted = set()
    for candle_manager in self._candle_managers:
        candle_manager._prepend_parsed(candles_, admitted=admitted)
    self.calculate()

purge

purge(source: Source | None = None)

Takes Indicator name and removes all readings for said indicator. Indicator name must be exact

Source code in hexital/core/hexital.py
def purge(self, source: Source | None = None):
    """Takes Indicator name and removes all readings for said indicator.
    Indicator name must be exact"""
    if not source:
        for indicator in self._indicators.values():
            indicator.purge()
    elif indicator := self._find_indicator(source):
        indicator.purge()

reading

reading(source: Source, index: int = -1) -> Reading

Attempts to retrieve a reading with a given Indicator name. name can use ~hexital.core.constants.NESTED_DELI to find a nested reading, e.g. MACD_12_26_9:signal

Source code in hexital/core/hexital.py
def reading(self, source: Source, index: int = -1) -> Reading:
    """Attempts to retrieve a reading with a given Indicator name.
    `name` can use `~hexital.core.constants.NESTED_DELI` to find a nested
    reading, e.g. ``MACD_12_26_9:signal``
    """
    return self._find_reading(source, index)

recalculate

recalculate(source: Source | None = None)

Purge's all indicator reading's and re-calculates them all, ideal for changing an indicator parameters midway.

Source code in hexital/core/hexital.py
def recalculate(self, source: Source | None = None):
    """Purge's all indicator reading's and re-calculates them all,
    ideal for changing an indicator parameters midway."""
    if not source:
        for indicator in self._indicators.values():
            indicator.purge()
            indicator.calculate()
    elif indicator := self._find_indicator(source):
        indicator.purge()
        indicator.calculate()

remove_indicator

remove_indicator(source: Source)

Removes an indicator from running within hexital

Source code in hexital/core/hexital.py
def remove_indicator(self, source: Source):
    """Removes an indicator from running within hexital"""
    indicator = self._find_indicator(source)
    if not indicator:
        return

    indicator.purge()
    self._indicators.pop(indicator.name)

series

series(source: Source) -> list[Reading]

Find given indicator and returns the readings as a list Full Name of the indicator E.G EMA_12 OR MACD_12_26_9:signal

Source code in hexital/core/hexital.py
def series(self, source: Source) -> list[Reading]:
    """Find given indicator and returns the readings as a list
    Full Name of the indicator E.G `EMA_12` OR `MACD_12_26_9:signal`"""
    return self._find_series(source)

Ichimoku dataclass

Ichimoku(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    tenkan: int = 9,
    kijun: int = 26,
    senkou: int = 52,
    include_chikou: bool = True,
    offset: int = 0
)

Bases: Indicator[dict[str, float | None]]

Ichimoku Kinko Hyo - ICHIMOKU

Ichimoku is a multi-line trend indicator composed of a conversion line, base line, two leading spans, and an optional chikou span.

This implementation is incremental and does not require future candle data. Shifted components are written to their target candle indexes as new candles arrive, so the chikou span updates older candle readings in place.

Output type: Dict["Lead_A": float, "Lead_B": float, "Conversion": float, "Base": float, "Span": float]

Parameters:

Name Type Description Default
tenkan int

Tenkan period. Defaults to 9

9
kijun int

Kijun period. Defaults to 26

26
senkou int

Senkou period. Defaults to 52

52
include_chikou bool

Include the chikou span. Defaults to True

True
offset int

Post shift. Defaults to 0

0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Indicator dataclass

Indicator(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4
)

Bases: Generic[V], ABC

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

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

JMA dataclass

JMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 7,
    source: Source = "close",
    phase: float = 0.0
)

Bases: Indicator[float | None]

Jurik Moving Average Average - JMA

The JMA is an adaptive moving average that aims to reduce lag and improve responsiveness to price changes compared to traditional moving averages. By incorporating volatility and phase shift components, the JMA seeks to provide traders with a more accurate and timely representation of market trends.

Sources

https://c.mql5.com/forextsd/forum/164/jurik_1.pdf

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 7

7
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'
phase float

How heavy/light the average is [-100, 100]. Defaults to 0.0

0.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

KAMA dataclass

KAMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    fast: int = 2,
    slow: int = 30,
    source: Source = "close"
)

Bases: Indicator[float | None]

Kaufman's Adaptive Moving Average - KAMA

KAMA adapts its smoothing based on market efficiency. It responds faster in directional moves and slows down in noisy ranges.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/overlap/help/pandas_ta.overlap.kama.html

Output type: float

Parameters:

Name Type Description Default
period int

Efficiency ratio lookback. Defaults to 10.

10
fast int

Fast EMA length. Defaults to 2.

2
slow int

Slow EMA length. Defaults to 30.

30
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

KC dataclass

KC(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 20,
    source: Source = "close",
    multiplier: float = 2.0,
    mamode: str = "ema",
    tr: bool = True
)

Bases: Indicator[dict[str, float | None]]

Keltner Channel - KC

Keltner channel is a technical analysis indicator showing a central moving average line plus channel lines at a distance above and below. A popular volatility indicator similar to Bollinger Bands and Donchian Channels.

Sources

https://www.investopedia.com/terms/k/keltnerchannel.asp

Output type: Dict["lower": float, "band": float, "upper": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 20

20
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'
multiplier float

A positive float to multiply the bands. Defaults to 2.0

2.0
mamode str

Center line average type. One of "ema" or "sma". Defaults to "ema"

'ema'
tr bool

Use true range for the channel width. Defaults to True

True

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

KST dataclass

KST(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    roc1: int = 10,
    roc2: int = 15,
    roc3: int = 20,
    roc4: int = 30,
    sma1: int = 10,
    sma2: int = 10,
    sma3: int = 10,
    sma4: int = 15,
    signal_period: int = 9
)

Bases: Indicator[dict[str, float | None]]

Know Sure Thing - KST

KST combines four smoothed rate-of-change series into a weighted momentum oscillator with a signal line.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/momentum/help/pandas_ta.momentum.kst.html

Output type: Dict["KST": float, "signal": float]

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

LinearRegression dataclass

LinearRegression(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close"
)

Bases: Indicator[float | None]

Linear Regression - LR

Linear Regression fits a least-squares line over a rolling window and returns the line value using the same convention as pandas-ta linreg.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/overlap/help/pandas_ta.overlap.linreg.html

Output type: float

Parameters:

Name Type Description Default
period int

Rolling window length. Defaults to 14.

14
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

MACD dataclass

MACD(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    source: Source = "close",
    fast_period: int = 12,
    slow_period: int = 26,
    signal_period: int = 9
)

Bases: Indicator[dict[str, float | None]]

Moving Average Convergence Divergence - MACD

The MACD is a popular indicator to that is used to identify a security's trend. While APO and MACD are the same calculation, MACD also returns two more series called Signal and Histogram. The Signal is an EMA of MACD and the Histogram is the difference of MACD and Signal.

Sources

https://www.investopedia.com/ask/answers/122314/what-exponential-moving-average-ema-formula-and-how-ema-calculated.asp

Output type: Dict["MACD": float, "signal": float, "histogram": float]

Parameters:

Name Type Description Default
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'
fast_period int

How many Periods to use for fast EMA. Defaults to 12

12
slow_period int

How many Periods to use for slow EMA. Defaults to 26

26
signal_period int

How many Periods to use for MACD signal. Defaults to 9

9

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

MFI dataclass

MFI(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close"
)

Bases: Indicator[float | None]

Money Flow Index - MFI

The money flow index (MFI) is an oscillator that ranges from 0 to 100. It is used to show the money flow over several days.

Sources

https://www.tradingview.com/wiki/Money_Flow_(MFI)

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

MOP dataclass

MOP(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 2,
    source: Source = "close"
)

Bases: Indicator[float | None]

Midpoint Over Period - MOP

A technical analysis tool that evaluates the average price movement by calculating the midpoint between the highest and lowest points over a specified period. This indicator aims to provide a smoother representation of price action, avoiding the choppiness of extreme highs and lows.

Sources

https://trendspider.com/learning-center/understanding-and-applying-the-midpoint-over-period-indicator-in-trading/

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 2

2
source str()

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

NATR dataclass

NATR(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14
)

Bases: Indicator[float | None]

Normalized Average True Range - NATR

NATR expresses ATR as a percentage of the current close, making volatility readings comparable across instruments with different price levels.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/volatility/help/pandas_ta.volatility.natr.html

Output type: float

Parameters:

Name Type Description Default
period int

How many periods to use. Defaults to 14.

14

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

OBV dataclass

OBV(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4
)

Bases: Indicator[float]

On-Balance Volume - OBC

On-balance volume (OBV) is a technical analysis indicator intended to relate price and volume in the stock market. OBV is based on a cumulative total volume.

Sources

https://en.wikipedia.org/wiki/On-balance_volume

Output type: float

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

PivotPoints dataclass

PivotPoints(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4
)

Bases: Indicator[dict[str, float | None]]

Pivot Points - PP

Pivot point is a price level that is used by traders as a possible indicator of market movement. A pivot point is calculated as an average of significant prices (high, low, close) from the performance of a market in the prior trading period. If the market in the following period trades above the pivot point it is 1usually evaluated as a bullish sentiment, whereas trading below the pivot point is seen as bearish.

Sources

https://en.wikipedia.org/wiki/Pivot_point_(technical_analysis)

Output type: Dict["S1": float, "R1": float, "S2": float, "R2": float]

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

RMA dataclass

RMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close"
)

Bases: Indicator[float | None]

wildeR's Moving Average - RMA

Wilder's Moving Average places more emphasis on recent price movements than other moving averages. This makes it a more responsive tool for short-term traders who need to adapt quickly to changing market conditions.

Sources

https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/V-Z/WildersSmoothing https://www.incrediblecharts.com/indicators/wilder_moving_average.php

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

ROC dataclass

ROC(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close"
)

Bases: Indicator[float | None]

Rate Of Change - ROC

The Price Rate of Change (ROC) indicator in trading refers to the percentage change between the current price and the price of a set number of periods ago. It is used to identify the momentum of price movement and help traders make informed decisions regarding buying or selling assets. This indicator is calculated by dividing the difference between the current price and the price of a set number of periods ago by the previous price and multiplying by 100.

Sources

https://en.wikipedia.org/wiki/Momentum_(technical_analysis)

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

RSI dataclass

RSI(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close"
)

Bases: Indicator[float | None]

Relative Strength Index - RSI

The Relative Strength Index is popular momentum oscillator used to measure the velocity as well as the magnitude of directional price movements.

Sources

https://www.tradingview.com/support/solutions/43000502338-relative-strength-index-rsi/

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

RVI dataclass

RVI(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close"
)

Bases: Indicator[float | None]

Relative Vigor Index - RVI

The Relative Vigor Index, or RVI, is a popular member of the “Oscillator” family of technical indicators. although the creator of the Relative Vigor Index is unknown, its design is very similar to Stochastics except that the closing price is compared with the Open rather than the Low price for the period.

Sources

https://www.thinkmarkets.com/en/learn-to-trade/indicators-and-patterns/indicators/relative-vigor-index-rvi-indicator/

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

RegressionChannel dataclass

RegressionChannel(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close",
    std: float = 2.0
)

Bases: Indicator[dict[str, float | None]]

Regression Channel

Regression Channel fits a rolling least-squares line and places upper and lower bands around it using the residual standard deviation.

Output type: Dict["lower": float, "mid": float, "upper": float]

Parameters:

Name Type Description Default
period int

Rolling window length. Defaults to 14.

14
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'
std float

Residual standard deviation multiplier. Defaults to 2.0.

2.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

RegressionSlope dataclass

RegressionSlope(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close"
)

Bases: Indicator[float | None]

Regression Slope - LRm

Regression Slope returns the least-squares slope over a rolling window.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/overlap/help/pandas_ta.overlap.linreg.html

Output type: float

Parameters:

Name Type Description Default
period int

Rolling window length. Defaults to 14.

14
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

SMA dataclass

SMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close"
)

Bases: Indicator[float | None]

Simple Moving Average - SMA

The Simple Moving Average is the classic moving average that is the equally weighted average over n periods.

Sources

https://www.investopedia.com/terms/s/sma.asp

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

STDEV dataclass

STDEV(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 30,
    source: Source = "close"
)

Bases: Indicator[float | None]

Rolling Standard Deviation - STDEV

You use a rolling stdev when you expect the standard deviation to change over time. As long as the standard deviation is changing slowly enough, we should be able to see the change in the standard deviation over time if we use the right size window.

Sources

https://jonisalonen.com/2014/efficient-and-accurate-rolling-standard-deviation/

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 30

30
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

STDEVT dataclass

STDEVT(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close",
    multiplier: float = 2.0
)

Bases: Indicator[float | None]

Standard Deviation Threshold - STDEVT

Standard Deviation while calculating threshold returning boolean signal if change to input is higher than threshold

Sources

ChatGPT

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'
multiplier float

A positive float to multiply the Deviation. Defaults to 2.0

2.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

STOCH dataclass

STOCH(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    slow_period: int = 3,
    smoothing_k: int = 3,
    source: Source = "close"
)

Bases: Indicator[dict[str, float | None]]

Stochastic - STOCH

The Stochastic Oscillator (STOCH) was developed by George Lane in the 1950's. He believed this indicator was a good way to measure momentum because changes in momentum precede changes in price.

It is a range-bound oscillator with two lines moving between 0 and 100. The first line (%K) displays the current close in relation to the period's high/low range. The second line (%D) is a Simple Moving Average of the %K line. The most common choices are a 14 period %K and a 3 period SMA for %D.

%K = SMA(100 * (Current Close - Lowest Low) / (Highest High - Lowest Low), smoothK) %D = SMA(%K, periodD)

Sources

https://www.tradingview.com/wiki/Stochastic_(STOCH)

Output type: Dict["stoch": float, "k": float, "d": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 14

14
slow_period int

How many Periods to use on smoothing d. Defaults to 3

3
smoothing_k int

How many Periods to use on smoothing K. Defaults to 3

3
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Squeeze dataclass

Squeeze(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    bb_length: int = 20,
    bb_std: float = 2.0,
    kc_length: int = 20,
    kc_scalar: float = 1.5,
    mom_length: int = 12,
    mom_smooth: int = 6,
    mamode: str = "sma",
    period: int | None = None
)

Bases: Indicator[dict[str, float | int | None]]

Squeeze

The TTM Squeeze is a volatility and momentum indicator. This implementation matches the default pandas_ta.squeeze output used by the source-of-truth fixture: Bollinger Bands versus SMA-based Keltner Channels plus mom(12) smoothed by sma(6).

Output type: Dict["SQZ": float, "ON": int, "OFF": int]

Parameters:

Name Type Description Default
bb_length int

Bollinger Bands period. Defaults to 20

20
bb_std float

Bollinger Bands standard deviation multiplier. Defaults to 2.0

2.0
kc_length int

Keltner Channel period. Defaults to 20

20
kc_scalar float

Keltner Channel scalar. Defaults to 1.5

1.5
mom_length int

Momentum period. Defaults to 12

12
mom_smooth int

Momentum smoothing period. Defaults to 6

6
mamode str

Momentum smoothing average type. One of "sma" or "ema"

'sma'
period int | None

Backwards-compatible alias for bb_length and kc_length

None

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

SqueezePro dataclass

SqueezePro(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    bb_length: int = 20,
    bb_std: float = 2.0,
    kc_length: int = 20,
    kc_scalar_wide: float = 2.0,
    kc_scalar_normal: float = 1.5,
    kc_scalar_narrow: float = 1.0,
    mom_length: int = 12,
    mom_smooth: int = 6,
    mamode: str = "sma"
)

Bases: Indicator[dict[str, float | int | None]]

SqueezePro

Squeeze Pro extends the classic squeeze by comparing Bollinger Bands against three Keltner Channel widths while keeping the same momentum oscillator.

Output type: Dict["SQZ": float, "Wide": int, "Normal": int, "Narrow": int, "OFF": int]

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

State

State(parent: Indicator, managed: Managed)

Internal state backed by a managed child indicator.

Use via Indicator.add_state() rather than constructing directly. Dictionary keys map to fields stored on each candle's sub_indicators.

Methods:

Name Description
prev

Previous reading for the whole state or a single field.

reading

Current reading for the whole state or a single field.

set

Replace the stored state for the current or given candle.

source

Reference a state field as an indicator source.

update

Merge fields into dict state for the current or given candle.

Attributes:

Name Type Description
managed Managed

Underlying managed child, e.g. as an EMA source.

Source code in hexital/core/indicator/managed.py
def __init__(self, parent: Indicator, managed: Managed):
    self._parent = parent
    self._managed = managed
    self._sources: dict[str, NestedSource] = {}

managed property

managed: Managed

Underlying managed child, e.g. as an EMA source.

prev

prev(key: str | None = None, default: T | None = None) -> Reading | T

Previous reading for the whole state or a single field.

Source code in hexital/core/indicator/managed.py
def prev(self, key: str | None = None, default: T | None = None) -> Reading | T:
    """Previous reading for the whole state or a single field."""
    if key is None:
        return self._parent.prev_reading(self._managed, default)  # type: ignore
    return self._parent.prev_reading(self.source(key), default)  # type: ignore

reading

reading(key: str | None = None, default: T | None = None) -> Reading | T

Current reading for the whole state or a single field.

Source code in hexital/core/indicator/managed.py
def reading(self, key: str | None = None, default: T | None = None) -> Reading | T:
    """Current reading for the whole state or a single field."""
    if key is None:
        value = self._managed.reading()
        return value if value is not None else default  # type: ignore
    return self._parent.reading(self.source(key), default=default)  # type: ignore

set

set(reading: Reading, index: int | None = None) -> None

Replace the stored state for the current or given candle.

Source code in hexital/core/indicator/managed.py
def set(self, reading: Reading, index: int | None = None) -> None:
    """Replace the stored state for the current or given candle."""
    self._managed.set_reading(reading, index=index)  # type: ignore

source

source(key: str) -> NestedSource

Reference a state field as an indicator source.

Source code in hexital/core/indicator/managed.py
def source(self, key: str) -> NestedSource:
    """Reference a state field as an indicator source."""
    if key not in self._sources:
        self._sources[key] = NestedSource(self._managed, key)
    return self._sources[key]

update

update(index: int | None = None, **values: Reading) -> None

Merge fields into dict state for the current or given candle.

Source code in hexital/core/indicator/managed.py
def update(self, index: int | None = None, **values: Reading) -> None:
    """Merge fields into dict state for the current or given candle."""
    current = self._parent.reading(self._managed, index=index, default={})
    if isinstance(current, dict):
        self._managed.set_reading({**current, **values}, index=index)  # type: ignore
    else:
        self._managed.set_reading(values, index=index)  # type: ignore

Supertrend dataclass

Supertrend(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 7,
    source: Source = "close",
    multiplier: float = 3.0
)

Bases: Indicator[dict[str, float | int | None]]

Supertrend

It is used to identify market trends and potential entry and exit points in trading. The indicator is based on two dynamic values, period and multiplier, and incorporates the concept of Average True Range (ATR) to measure market volatility. The SuperTrend Indicator generates buy and sell signals by plotting a line on the price chart.

Output type: Dict["trend": float, "direction": int, "short": float]

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 7

7
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'
multiplier float

A positive float to multiply the ATR. Defaults to 3.0

3.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

TEMA dataclass

TEMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close"
)

Bases: Indicator[float | None]

Triple Exponential Moving Average - TEMA

TEMA reduces lag further than DEMA by combining three EMA layers into one smoothed output.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/overlap/help/pandas_ta.overlap.tema.html

Output type: float

Parameters:

Name Type Description Default
period int

How many periods to use. Defaults to 10.

10
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

TR dataclass

TR(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4
)

Bases: Indicator[float | None]

True Range - TR

An method to expand a classical range (high minus low) to include possible gap scenarios.

Sources

https://www.macroption.com/true-range/

Output type: float

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

TRIX dataclass

TRIX(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 30,
    signal_period: int = 9,
    scalar: float = 100.0,
    source: Source = "close"
)

Bases: Indicator[dict[str, float | None]]

Triple Exponential Average Oscillator - TRIX

TRIX measures the percent rate of change of a triple-smoothed EMA and pairs it with a simple moving average signal line.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/momentum/help/pandas_ta.momentum.trix.html

Output type: Dict["TRIX": float, "signal": float]

Parameters:

Name Type Description Default
period int

EMA lookback. Defaults to 30.

30
signal_period int

Signal SMA lookback. Defaults to 9.

9
scalar float

Multiplier applied to the percent change. Defaults to 100.0.

100.0
source str

Which input field to calculate the indicator from. Defaults to "close".

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

TSI dataclass

TSI(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 25,
    smooth_period: int = 0,
    source: Source = "close"
)

Bases: Indicator[float | None]

True Strength Index - TSI TSI attempts to show both trend direction and overbought/oversold conditions, using moving averages of the underlying momentum of a financial instrument.

Sources

https://school.stockcharts.com/doku.php?id=technical_indicators:true_strength_index

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 25

25
smooth_period int

How much to smooth with EMA defaults: (period / 2) + (period % 2 > 0). Defaults to halve of period

0
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

TimeFrame

Bases: Enum

Pre-defined TimeFrame values

UO dataclass

UO(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    fast: int = 7,
    medium: int = 14,
    slow: int = 28,
    fast_w: float = 4.0,
    medium_w: float = 2.0,
    slow_w: float = 1.0
)

Bases: Indicator[float | None]

Ultimate Oscillator - UO

The Ultimate Oscillator blends short, medium, and long buying pressure ratios to reduce false divergence signals from single-window oscillators.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/momentum/help/pandas_ta.momentum.uo.html

Output type: float

Parameters:

Name Type Description Default
fast int

Fast lookback. Defaults to 7.

7
medium int

Medium lookback. Defaults to 14.

14
slow int

Slow lookback. Defaults to 28.

28
fast_w float

Fast period weight. Defaults to 4.0.

4.0
medium_w float

Medium period weight. Defaults to 2.0.

2.0
slow_w float

Slow period weight. Defaults to 1.0.

1.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

VWAP dataclass

VWAP(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    anchor: str | TimeFrame | timedelta | int | None = "D"
)

Bases: Indicator[float]

Volume-Weighted Average Price - VWAP

The volume-weighted average price is a technical analysis indicator used on intraday charts that resets at the start of every new trading session. Resets on the configured anchor timeframe (default: daily "D").

Sources

https://www.investopedia.com/terms/v/vwap.asp

Output type: float

Parameters:

Name Type Description Default
anchor Optional[str | TimeFrame | timedelta | int]

How to anchor VWAP, Depends on the index values, uses TimeFrame

'D'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

VWMA dataclass

VWMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10
)

Bases: Indicator[float | None]

Volume Weighted Moving Average - VWMA

VWMA is the ratio of the value of a security or financial asset traded to the total volume of transactions during a trading session. It is a measure of the average trading price for the period.

Sources

https://www.investopedia.com/ask/answers/071414/whats-difference-between-moving-average-and-weighted-moving-average.asp

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

Vortex dataclass

Vortex(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    drift: int = 1
)

Bases: Indicator[dict[str, float | None]]

Vortex Indicator - VTX

Vortex compares directional movement against total true range to highlight bullish and bearish trend dominance.

Sources

https://tradingstrategy.ai/docs/api/technical-analysis/trend/help/pandas_ta.trend.vortex.html

Output type: Dict["VTXP": float, "VTXM": float]

Parameters:

Name Type Description Default
period int

Rolling window length. Defaults to 14.

14
drift int

Previous candle offset for movement comparison. Defaults to 1.

1

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

WMA dataclass

WMA(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 10,
    source: Source = "close"
)

Bases: Indicator[float | None]

Weighted Moving Average - WMA

A Weighted Moving Average puts more weight on recent data and less on past data. This is done by multiplying each bar's price by a weighting factor. Because of its unique calculation, WMA will follow prices more closely than a corresponding Simple Moving Average.

Sources

https://www.investopedia.com/ask/answers/071414/whats-difference-between-moving-average-and-weighted-moving-average.asp

Output type: float

Parameters:

Name Type Description Default
period int

How many Periods to use. Defaults to 10

10
source str

Which input field to calculate the Indicator. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

WillR dataclass

WillR(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 14,
    source: Source = "close"
)

Bases: Indicator[float | None]

William's Percent R - WILLR

Williams %R is a momentum oscillator that measures the current close relative to the highest high and lowest low over a rolling lookback period.

Output type: float

Parameters:

Name Type Description Default
period int

How many periods to use. Defaults to 14

14
source str

Which input field to compare against the rolling range. Defaults to "close"

'close'

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

ZScore dataclass

ZScore(
    *,
    candles: list[Candle] = list(),
    name: str = "",
    timeframe: TimeFramesSource | None = None,
    timeframe_fill: bool = False,
    candle_life: timedelta | None = None,
    candlestick: CandlestickType | str | None = None,
    rounding: int | None = 4,
    period: int = 30,
    source: Source = "close",
    std: float = 1.0
)

Bases: Indicator[float | None]

Rolling Z Score - ZS

The rolling z-score measures how far the current value is from its rolling mean in units of rolling standard deviation. It is commonly used to detect statistical extremes and mean-reversion conditions.

Output type: float

Parameters:

Name Type Description Default
period int

How many periods to use. Defaults to 30

30
source str

Which input field to calculate the indicator from. Defaults to "close"

'close'
std float

Standard deviation multiplier applied to the denominator. Defaults to 1.0

1.0

Methods:

Name Description
add_child

Register a child indicator that shares this indicator's candles.

add_child_after

Register a child calculated after the parent's reading is stored.

add_child_managed

Register a child calculated only when explicitly invoked.

add_state

Register hidden state storage for incremental calculations.

append

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

at

Reading at a specific candle index — shorthand for reading.

at_src

Reading at index for this indicator's configured source.

calculate

Calculate the TA values, will calculate for all the Candles,

calculate_index

Calculate the TA values, will calculate a index range the Candles, will re-calculate

insert

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

prepend

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

prev

Previous reading — shorthand for prev_reading.

prev_src

Previous reading for this indicator's configured source.

reading

Simple method to get an indicator reading from the index

reading_count

Returns how many instance of the given indicator exist

reading_period

Will return True if the given indicator goes back as far as amount,

recalculate

Re-calculate this indicator value for all Candles

series

Retrieve the indicator readings for within the candles as a list.

src

Current reading for this indicator's configured source.

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

candle_manager property writable

candle_manager: CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

settings property

settings: dict

Retrieve the settings required to regenerate this indicator in a dictionary format.

This property compiles the configuration details of the indicator, excluding attributes that are irrelevant for generation (e.g., candles and sub-indicators). It ensures the output dictionary is clean and contains only the necessary settings for recreating the indicator.

Special handling is included for attributes like candlestick and timeframe, ensuring their values are properly formatted.

Returns:

Name Type Description
dict dict

A dictionary containing the indicator's settings, ready for regeneration. - indicator (str): The name of the indicator. - Additional keys correspond to other configuration attributes of the indicator.

add_child

add_child(indicator: Indicator, when: ChildWhen | str = BEFORE) -> Indicator

Register a child indicator that shares this indicator's candles.

Parameters:

Name Type Description Default
indicator Indicator

The child indicator to attach.

required
when ChildWhen | str

When the child is calculated relative to the parent at each index. :attr:ChildWhen.BEFORE runs before _calculate_reading. :attr:ChildWhen.AFTER runs after the parent's reading is stored. :attr:ChildWhen.MANUAL is only calculated when explicitly invoked (e.g. via Managed.set_reading or calculate_index).

BEFORE
Source code in hexital/core/indicator/core.py
def add_child(
    self,
    indicator: Indicator,
    when: ChildWhen | str = ChildWhen.BEFORE,
) -> Indicator:
    """Register a child indicator that shares this indicator's candles.

    Args:
        indicator: The child indicator to attach.
        when: When the child is calculated relative to the parent at each index.
            :attr:`ChildWhen.BEFORE` runs before `_calculate_reading`.
            :attr:`ChildWhen.AFTER` runs after the parent's reading is stored.
            :attr:`ChildWhen.MANUAL` is only calculated when explicitly invoked
            (e.g. via `Managed.set_reading` or `calculate_index`).
    """
    when = _normalize_when(when)
    self._prefix_generated_name(indicator, f"{self.name}-{indicator.name}")
    return self._bind_child(indicator, when)

add_child_after

add_child_after(indicator: Indicator) -> Indicator

Register a child calculated after the parent's reading is stored.

Source code in hexital/core/indicator/core.py
def add_child_after(self, indicator: Indicator) -> Indicator:
    """Register a child calculated after the parent's reading is stored."""
    return self.add_child(indicator, when=ChildWhen.AFTER)

add_child_managed

add_child_managed(indicator: Indicator) -> Indicator

Register a child calculated only when explicitly invoked.

Source code in hexital/core/indicator/core.py
def add_child_managed(self, indicator: Indicator) -> Indicator:
    """Register a child calculated only when explicitly invoked."""
    if isinstance(indicator, Managed):
        self._prefix_generated_name(indicator, f"{self.name}_data")
    return self.add_child(indicator, when=ChildWhen.MANUAL)

add_state

add_state(name: str | None = None) -> State

Register hidden state storage for incremental calculations.

Source code in hexital/core/indicator/core.py
def add_state(self, name: str | None = None) -> State:
    """Register hidden state storage for incremental calculations."""
    state_name = name if name is not None else f"{self.name}_data"
    managed = Managed(name=state_name)
    return State(self, self.add_child(managed, when=ChildWhen.MANUAL))

append

append(candles: Candles)

Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to append.

required
Source code in hexital/core/indicator/core.py
def append(self, candles: Candles):
    """Appends a Candle or a chronological ordered list of Candle's to the end of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to append.
    """
    self._candle_mngr.append(candles)
    self.calculate()

at

at(
    index: int, source: Source | None = None, default: T | None = None
) -> V | T

Reading at a specific candle index — shorthand for reading.

Source code in hexital/core/indicator/core.py
def at(
    self,
    index: int,
    source: Source | None = None,
    default: T | None = None,
) -> V | T:
    """Reading at a specific candle index — shorthand for `reading`."""
    return self.reading(source, index=index, default=default)

at_src

at_src(index: int, default: T | None = None) -> V | T

Reading at index for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def at_src(self, index: int, default: T | None = None) -> V | T:
    """Reading at ``index`` for this indicator's configured ``source``."""
    return self.reading(
        getattr(self, "source", "close"), index=index, default=default
    )

calculate

calculate()

Calculate the TA values, will calculate for all the Candles, where this indicator is missing

Source code in hexital/core/indicator/core.py
def calculate(self):
    """Calculate the TA values, will calculate for all the Candles,
    where this indicator is missing"""
    self.check_initialised()

    for index in range(self._find_calc_index(), len(self.candles)):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(
            self._calculate_reading(index=index), round_by=self.rounding
        )

        if index < len(self.candles) - 1 and self._reading_dup(
            reading, self.candles[index]
        ):
            break

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

calculate_index

calculate_index(start_index: int, end_index: int | None = None)

Calculate the TA values, will calculate a index range the Candles, will re-calculate

Source code in hexital/core/indicator/core.py
def calculate_index(self, start_index: int, end_index: int | None = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    self.check_initialised()

    start_index = absindex(start_index, len(self.candles))

    if end_index is not None:
        end_index = absindex(end_index, len(self.candles))
    else:
        end_index = start_index

    for index in range(start_index, end_index + 1):
        self._set_active_index(index)
        self._calculate_children(ChildWhen.BEFORE, index)

        reading = round_values(self._calculate_reading(index=index), self.rounding)

        self._set_reading(reading, index)
        self._calculate_children(ChildWhen.AFTER, index)

insert

insert(candles: Candles)

insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def insert(self, candles: Candles):
    """insert a Candle or a list of Candle's to the Indicator Candles. This accepts any order or placement. This will sort, re-sample and re-calculate all Candles.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.insert(candles)
    self.calculate_index(0, -1)

prepend

prepend(candles: Candles)

Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

Parameters:

Name Type Description Default
candles Candles

The Candle or List of Candle's to prepend.

required
Source code in hexital/core/indicator/core.py
def prepend(self, candles: Candles):
    """Prepends a Candle or a chronological ordered list of Candle's to the front of the Indicator Candle's. This will only re-sample and re-calculate the new Candles, with minor overlap.

    Args:
        candles: The Candle or List of Candle's to prepend.
    """
    self._candle_mngr.prepend(candles)
    self.calculate()

prev

prev(source: Source | None = None, default: T | None = None) -> V | T

Previous reading — shorthand for prev_reading.

Source code in hexital/core/indicator/core.py
def prev(self, source: Source | None = None, default: T | None = None) -> V | T:
    """Previous reading — shorthand for `prev_reading`."""
    return self.prev_reading(source, default)

prev_src

prev_src(default: T | None = None) -> V | T

Previous reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def prev_src(self, default: T | None = None) -> V | T:
    """Previous reading for this indicator's configured ``source``."""
    return self.prev_reading(getattr(self, "source", "close"), default=default)

reading

reading(
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T

Simple method to get an indicator reading from the index

Source code in hexital/core/indicator/core.py
def reading(
    self,
    source: Source | None = None,
    index: int | None = None,
    default: T | None = None,
) -> V | T:
    """Simple method to get an indicator reading from the index"""
    value = self._find_reading(source, index)
    return value if value is not None else default  # type: ignore

reading_count

reading_count(source: Source | None = None, index: int | None = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator/core.py
def reading_count(
    self, source: Source | None = None, index: int | None = None
) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        *self._find_candles(source),
        index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, source: Source | None = None, index: int | None = None
) -> bool

Will return True if the given indicator goes back as far as amount, It's true if exactly or more than. Period will be period -1

Source code in hexital/core/indicator/core.py
def reading_period(
    self, period: int, source: Source | None = None, index: int | None = None
) -> bool:
    """Will return True if the given indicator goes back as far as amount,
    It's true if exactly or more than. Period will be period -1"""
    return reading_period(
        *self._find_candles(source),
        period,
        index if index is not None else self._active_index,
    )

recalculate

recalculate()

Re-calculate this indicator value for all Candles

Source code in hexital/core/indicator/core.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

series

series(name: Source | None = None) -> list[Reading | V]

Retrieve the indicator readings for within the candles as a list.

This method collects the readings of a specified indicator for all candles and returns them as a list. If no name is provided, the generated name of the indicator is used.

Parameters:

Name Type Description Default
name str | None

The name of the indicator to retrieve. Defaults to self.name if not provided.

None

Returns:

Type Description
list[Reading | V]

List[float | dict | None]: A list containing the indicator values for each candle. The values may be floats, dictionaries (for complex indicators), or None if no reading is available.

Source code in hexital/core/indicator/core.py
def series(self, name: Source | None = None) -> list[Reading | V]:
    """
    Retrieve the indicator readings for within the candles as a list.

    This method collects the readings of a specified indicator for all candles
    and returns them as a list. If no name is provided, the generated name of
    the indicator is used.

    Args:
        name (str | None): The name of the indicator to retrieve.
                              Defaults to `self.name` if not provided.

    Returns:
        List[float | dict | None]: A list containing the indicator values for
                                   each candle. The values may be floats,
                                   dictionaries (for complex indicators),
                                   or `None` if no reading is available.
    """
    return self._find_series(name)  # type: ignore

src

src(default: T | None = None) -> V | T

Current reading for this indicator's configured source.

Source code in hexital/core/indicator/core.py
def src(self, default: T | None = None) -> V | T:
    """Current reading for this indicator's configured ``source``."""
    return self.reading(getattr(self, "source", "close"), default=default)

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)