pysatl_tsp.implementations.processor.t3_handler

Module Contents

Classes

T3Handler

Tim Tillson’s T3 Moving Average handler with lazy evaluation.

API

class pysatl_tsp.implementations.processor.t3_handler.T3Handler(length: int = 10, a: float = 0.7, source: pysatl_tsp.core.handler.Handler[Any, float | None] | None = None)[source]

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

Tim Tillson’s T3 Moving Average handler with lazy evaluation.

This handler implements the T3 adaptive moving average developed by Tim Tillson, which is designed to reduce lag and improve smoothness. The T3 is calculated as: T3 = c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3, where e1-e6 are sequentially computed EMAs.

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

Parameters:
  • length – Period for each EMA calculation, defaults to 10

  • a – Volume factor (0 < a < 1), controls smoothness vs. responsiveness, defaults to 0.7

  • source – Input data source, defaults to None

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 T3 handler with length of 5 and volume factor of 0.7
t3_handler = T3Handler(length=5, a=0.7)
t3_handler.set_source(data_source)

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

# Initial values will be None as the T3 calculation requires
# six sequential EMA calculations to establish

Initialization

Initialize a T3 moving average handler.

Parameters:
  • length – Period for each EMA calculation, defaults to 10

  • a – Volume factor (0 < a < 1), controls smoothness vs. responsiveness, defaults to 0.7

  • source – Input data source, defaults to None

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

Create an iterator that yields T3 moving average values.

This method constructs a pipeline of six cascaded EMA calculations, where each EMA takes the output of the previous one as input. The final T3 value is a weighted sum of the last four EMAs in the sequence.

Returns:

Iterator yielding T3 values

Raises:

ValueError – If no source has been set