pysatl_tsp.implementations.processor.tema_handler

Module Contents

Classes

TEMAHandler

Triple Exponential Moving Average (TEMA) handler with lazy evaluation.

API

class pysatl_tsp.implementations.processor.tema_handler.TEMAHandler(length: int)[source]

Bases: pysatl_tsp.core.handler.Handler[float | None, float | None]

Triple Exponential Moving Average (TEMA) handler with lazy evaluation.

This handler implements the TEMA indicator developed by Patrick Mulloy, which reduces lag by applying the formula: TEMA = 3 * (EMA1 - EMA2) + EMA3. Here EMA1 is the EMA of the original data, EMA2 is the EMA of EMA1, and EMA3 is the EMA of EMA2.

All calculations are performed lazily in a streaming fashion, computing values only when requested by the iterator.

Parameters:

length – Period for each EMA calculation

Example:
# Create a data source with numeric values
data_source = SimpleDataProvider([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0])

# Create a TEMA handler with length of 5
tema_handler = TEMAHandler(length=5)
tema_handler.set_source(data_source)

# Process the data
for value in tema_handler:
    print(value)

# Initial values will be None as TEMA requires three levels of EMA
# After initialization, TEMA values will follow the price action more closely
# than a regular EMA while maintaining smoothness

Initialization

Initialize a TEMA handler.

Parameters:

length – Period for each EMA calculation

__iter__() collections.abc.Iterator[float | None][source]

Create an iterator that yields TEMA values.

This method constructs a pipeline of three cascaded EMA calculations and applies the TEMA formula: 3 * (EMA1 - EMA2) + EMA3.

Returns:

Iterator yielding TEMA values

Raises:

ValueError – If no source has been set