Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:1kbgz Tributary Rolling Calculations

From Leeroopedia
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 w:

SMAt=1w∑i=t−w+1txi

Exponential Moving Average (EMA) with smoothing factor α:

EMAt=α⋅xt+(1−α)⋅EMAt−1

Where α=2w+1 for a window of size w.

RSI (Relative Strength Index):

RSI=100−1001+RS

Where RS=EMAgainsEMAlosses

MACD:

MACD=EMAfast−EMAslow

Signal=EMA(MACD,signal period)

# 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

Uses Heuristics

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment