Skip to content

WindowBase

QuantConnect.Indicators.WindowBase

WindowBase()
WindowBase(window_size: int)

Bases: Generic[QuantConnect_Indicators_WindowBase_T], Object, Iterable[QuantConnect_Indicators_WindowBase_T]

Provides a base class for types that maintain a rolling window history of values. This is the single source of truth for window logic shared between indicators and consolidators.

Signature descriptions:

  • Initializes a new instance of the WindowBase{T} class.

  • Initializes the rolling window with the given size.

DEFAULT_WINDOW_SIZE

DEFAULT_WINDOW_SIZE: int

The default number of values to keep in the rolling window history

window

window: RollingWindow[QuantConnect_Indicators_WindowBase_T]

A rolling window keeping a history of values. The most recent value is at index 0. Uses lazy initialization to support Python subclasses that do not call base constructors.

current

current: QuantConnect_Indicators_WindowBase_T

Gets the most recent value. The protected setter adds the value to the rolling window.

previous

previous: QuantConnect_Indicators_WindowBase_T

Gets the previous value, or default if fewer than two values have been produced.

__getitem__

__getitem__(i: int) -> QuantConnect_Indicators_WindowBase_T

Indexes the history window, where index 0 is the most recent value.

Parameters:

Name Type Description Default
i int

The index

required

Returns:

Type Description
QuantConnect_Indicators_WindowBase_T

The ith most recent value.

__iter__

__iter__() -> (
    Iterator[QuantConnect_Indicators_WindowBase_T]
)

get_enumerator

get_enumerator() -> (
    IEnumerator[QuantConnect_Indicators_WindowBase_T]
)

Returns an enumerator that iterates through the history window.

reset_window

reset_window() -> None

Resets the rolling window, clearing all stored values.

This Class is protected.