Skip to content

hexital

hexital

Modules:

Name Description
analysis
candlesticks
core
indicators
movement
patterns
utils

Classes:

Name Description
ADX

Average Directional Index - ADX

AROON

Aroon - AROON

ATR

Average True Range - ATR

Amorph

Amorph

BBANDS

Bollinger Bands - BBANDS

CMO

Chande Momentum Oscillator - CMO

Counter

Counter

Donchian

Donchian Channels - Donchian

EMA

Exponential Moving Average - EMA

HL

Highest Lowest - HL

HLA

High Low Average - HLA

HLCA

High Low Close Average - HLCA

HMA

Hull Moving Average - HMA

JMA

Jurik Moving Average Average - JMA

KC

Keltner Channel - KC

MACD

Moving Average Convergence Divergence - MACD

MFI

Money Flow Index - MFI

MOP

Midpoint Over Period - MOP

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

SMA

Simple Moving Average - SMA

STDEV

Rolling Standard Deviation - STDEV

STDEVT

Standard Deviation Threshold - STDEVT

STOCH

Stochastic - STOCH

Supertrend

Supertrend

TR

True Range - TR

TSI

True Strength Index - TSI

VWAP

Volume-Weighted Average Price - VWAP

VWMA

Volume Weighted Moving Average - VWMA

WMA

Weighted Moving Average - WMA

ADX dataclass

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

Bases: Indicator

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

None
multiplier Optional[float]

ADX smoothing multiplier. Defaults to 100.0

100.0

Methods:

Name Description
add_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

AROON dataclass

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

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

ATR dataclass

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

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

Amorph

Amorph(analysis: Callable, args: Optional[dict] = 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 Optional[dict]

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

None

Methods:

Name Description
add_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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: Optional[dict] = None, **kwargs):
    self._analysis_method = analysis
    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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

settings property

settings: dict

Returns a dict format of how this indicator can be generated

add_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

BBANDS dataclass

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

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

CMO dataclass

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

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

Counter dataclass

Counter(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    source: str,
    count_value: bool | int = True
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

Donchian dataclass

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

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

EMA dataclass

EMA(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 10,
    source: str = "close",
    smoothing: float = 2.0
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

HL dataclass

HL(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 100
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

HLA dataclass

HLA(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4
)

Bases: Indicator

High Low Average - HLA

Output type: float

Methods:

Name Description
add_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

HLCA dataclass

HLCA(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4
)

Bases: Indicator

High Low Close Average - HLCA

Output type: float

Methods:

Name Description
add_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

HMA dataclass

HMA(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 10,
    source: str = "close"
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

JMA dataclass

JMA(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 7,
    source: str = "close",
    phase: float = 0.0
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

KC dataclass

KC(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 20,
    source: str = "close",
    multiplier: float = 2.0
)

Bases: Indicator

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

Methods:

Name Description
add_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

MACD dataclass

MACD(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    source: str = "close",
    fast_period: int = 12,
    slow_period: int = 26,
    signal_period: int = 9
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

MFI dataclass

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

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

MOP dataclass

MOP(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 2,
    source: str = "close"
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

OBV dataclass

OBV(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

PivotPoints dataclass

PivotPoints(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

RMA dataclass

RMA(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 10,
    source: str = "close"
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

ROC dataclass

ROC(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 10,
    source: str = "close"
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

RSI dataclass

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

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

RVI dataclass

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

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

SMA dataclass

SMA(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 10,
    source: str = "close"
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

STDEV dataclass

STDEV(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 30,
    source: str = "close"
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

STDEVT dataclass

STDEVT(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 10,
    source: str = "close",
    multiplier: float = 2.0
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

STOCH dataclass

STOCH(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 14,
    slow_period: int = 3,
    smoothing_k: int = 3,
    source: str = "close"
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

Supertrend dataclass

Supertrend(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 7,
    source: str = "close",
    multiplier: float = 3.0
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

TR dataclass

TR(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

TSI dataclass

TSI(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 25,
    smooth_period: Optional[int] = None,
    source: str = "close"
)

Bases: Indicator

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

None
source str

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

'close'

Methods:

Name Description
add_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

VWAP dataclass

VWAP(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    anchor: Optional[str | TimeFrame | timedelta | int] = "D"
)

Bases: Indicator

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.

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

VWMA dataclass

VWMA(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 10
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()

WMA dataclass

WMA(
    *,
    candles: List[Candle] = list(),
    name: str = "",
    timeframe: Optional[str | TimeFrame | timedelta | int] = None,
    timeframe_fill: bool = False,
    candle_life: Optional[timedelta] = None,
    candlestick: Optional[CandlestickType | str] = None,
    rounding: Optional[int] = 4,
    period: int = 10,
    source: str = "close"
)

Bases: Indicator

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_managed_indicator

Adds managed sub indicator, this will not auto calculate with indicator

add_sub_indicator

Adds sub indicator, this will auto calculate with indicator

as_list

Retrieve the indicator values for all candles as a list.

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

purge

Remove this indicator value from all Candles

read_candle

Simple method to get an indicator reading from a candle,

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

Attributes:

Name Type Description
candle_manager CandleManager

The Candle Manager which controls TimeFrame, Trimming and collapsing

has_reading bool

Check if the indicator has generated values in the candles.

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

has_reading property

has_reading: bool

Check if the indicator has generated values in the candles.

This property determines whether the indicator readings have been generated for the associated candle data.

Returns:

Name Type Description
bool bool

True if the indicator readings exist in the candles; otherwise, False.

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_managed_indicator

add_managed_indicator(name: str, indicator: Managed | Indicator)

Adds managed sub indicator, this will not auto calculate with indicator

Source code in hexital/core/indicator.py
def add_managed_indicator(self, name: str, indicator: Managed | Indicator):
    """Adds managed sub indicator, this will not auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.managed_indicators[name] = indicator

add_sub_indicator

add_sub_indicator(indicator: Indicator, prior_calc: bool = True)

Adds sub indicator, this will auto calculate with indicator

Source code in hexital/core/indicator.py
def add_sub_indicator(self, indicator: Indicator, prior_calc: bool = True):
    """Adds sub indicator, this will auto calculate with indicator"""
    indicator._sub_indicator = True
    indicator._sub_calc_prior = prior_calc
    indicator.candle_manager = self._candles
    indicator.rounding = None
    self.sub_indicators[indicator.name] = indicator

as_list

as_list(name: Optional[str] = None) -> List[float | dict | None]

Retrieve the indicator values for all 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 Optional[str]

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

None

Returns:

Type Description
List[float | dict | None]

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.py
def as_list(self, name: Optional[str] = None) -> List[float | dict | None]:
    """
    Retrieve the indicator values for all 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 (Optional[str]): 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 [reading_by_candle(candle, name if name else self.name) for candle in self.candles]

calculate

calculate()

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

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

    self._calculate_sub_indicators(prior_calc=True)

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

        if self.candles[index].indicators.get(self.name) is not None:
            continue

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

    self._calculate_sub_indicators(prior_calc=False)

calculate_index

calculate_index(start_index: int, end_index: Optional[int] = None)

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

Source code in hexital/core/indicator.py
def calculate_index(self, start_index: int, end_index: Optional[int] = None):
    """Calculate the TA values, will calculate a index range the Candles, will re-calculate"""
    end_index = end_index if end_index else start_index + 1

    self._calculate_sub_indicators(True, start_index, end_index)

    for index in range(start_index, end_index):
        self._set_active_index(index)
        reading = round_values(self._calculate_reading(index=index), round_by=self.rounding)
        self._set_reading(reading, index)

    self._calculate_sub_indicators(False, start_index, end_index)

purge

purge()

Remove this indicator value from all Candles

Source code in hexital/core/indicator.py
def purge(self):
    """Remove this indicator value from all Candles"""
    self._candles.purge(
        {self.name}
        | {indicator.name for indicator in self.sub_indicators.values()}
        | {indicator.name for indicator in self.managed_indicators.values()}
    )

read_candle

read_candle(
    candle: Candle, name: Optional[str] = None, default: Optional[T] = None
) -> float | dict | None | T

Simple method to get an indicator reading from a candle, regardless of it's location

Source code in hexital/core/indicator.py
def read_candle(
    self,
    candle: Candle,
    name: Optional[str] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from a candle,
    regardless of it's location"""
    value = reading_by_candle(candle, name if name else self.name)
    return value if value is not None else default

reading

reading(
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T

Simple method to get an indicator reading from the index Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD

Source code in hexital/core/indicator.py
def reading(
    self,
    name: Optional[str] = None,
    index: Optional[int] = None,
    default: Optional[T] = None,
) -> float | dict | None | T:
    """Simple method to get an indicator reading from the index
    Name can use '.' to find nested reading, E.G 'MACD_12_26_9.MACD"""
    value = reading_by_candle(
        self.candles[index if index is not None else self._active_index],
        name if name else self.name,
    )
    return value if value is not None else default

reading_count

reading_count(name: Optional[str] = None, index: Optional[int] = None) -> int

Returns how many instance of the given indicator exist

Source code in hexital/core/indicator.py
def reading_count(self, name: Optional[str] = None, index: Optional[int] = None) -> int:
    """Returns how many instance of the given indicator exist"""
    return reading_count(
        self.candles,
        name=name if name else self.name,
        index=index if index is not None else self._active_index,
    )

reading_period

reading_period(
    period: int, name: Optional[str] = None, index: Optional[int] = 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.py
def reading_period(
    self, period: int, name: Optional[str] = None, index: Optional[int] = 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.candles,
        period=period,
        name=name if name else self.name,
        index=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.py
def recalculate(self):
    """Re-calculate this indicator value for all Candles"""
    self.purge()
    self.calculate()