Principle:1kbgz Tributary Rolling Calculations
| Knowledge Sources | |
|---|---|
| Domains | Streaming, Financial_Calculations, Time_Series |
| Last Updated | 2026-10-14 00:00 GMT |
Overview
A family of stateful streaming calculations that maintain a running aggregate (cumulative or windowed) over a data stream, producing a new output value for each input value.
Description
Rolling calculations are stateful transforms: each node maintains internal state (e.g., a cumulative sum, a sliding window, a previous value) that is updated on each tick. Unlike stateless transforms (e.g., Apply), rolling calculations produce values that depend on the entire history of the stream.
Categories:
- Cumulative: RollingSum, RollingCount, RollingMax, RollingMin, RollingAverage - aggregate over all values seen so far.
- Windowed: SMA (Simple Moving Average), EMA (Exponential Moving Average) - aggregate over a fixed-size sliding window.
- Differencing: Diff - returns the change from the previous value.
- Positional: First, Last - return the first or last value encountered.
- Technical Indicators: RSI (Relative Strength Index), MACD (Moving Average Convergence/Divergence) - composed indicators built from rolling calculations.
State is stored on the node instance via set(), which avoids clobbering node-critical attributes.
Usage
Use these when processing time-series or sequential data that requires historical context:
- Financial market data (moving averages, momentum indicators)
- IoT sensor aggregation (rolling mean, min/max)
- Any stream where recent history matters more than individual values
Theoretical Basis
Simple Moving Average (SMA) over a window of size :
Exponential Moving Average (EMA) with smoothing factor :
Where for a window of size .
RSI (Relative Strength Index):
Where
MACD:
# Abstract rolling calculation model (NOT real implementation)
def rolling_sum(node):
state = {"sum": 0}
def func(val):
state["sum"] += val
return state["sum"]
return Node(func=func, state=state)
Related Pages
Implemented By
- Implementation:1kbgz_Tributary_Streaming_Rolling_Calculations
- Implementation:1kbgz_Tributary_Streaming_Financial_Indicators