TimeBased Moving Functions (tmfunctions)
For most window calculations involving timeseries data, it's often required that the windows slide based on the time units. Therefore, DolphinDB introduces the timebased moving functions (tmfunctions) for such cases. The tmfunctions act similarly with the mfunctions when the parameter window is a DURATION value. However, the tmfunctions can be used in SQL statements to perform calculations on the columns of a table without requiring an indexed series or matrix.
Introduction

Higherorder function tmoving:
tmoving(func, T, funcArgs, window)
The tmfunctions are optimized for their specialized use cases and therefore
have a better performance than the higherorder function
tmoving()
.

Syntax templates for the tmfunctions:
tmfunc(T, X, window) tmfunc(T, X, Y, window)
Parameters:
T is a nonstrictly increasing vector of temporal or integral type. It cannot contain NULL values.
X (Y) is a vector of the same size as T.
window is a scalar of positive integer or DURATION type indicating the size of the sliding window.
List of Functions
Windowing Logic
For the tmfunctions, window can have the positive integral or DURATION type. The window size is measured by time.
For each element Ti in T:

When T is an integral value, the range of the corresponding window is (Ti  window, Ti]

When T is a temporal value, the range of the corresponding window is (temporalAdd(Ti, window), Ti]
The following example explains how the window slides:
T = [2022.01.01, 2022.01.02, 2022.01.03, 2022.01.06, 2022.01.07, 2022.01.08, 2022.01.10, 2022.01.11]
X = 1..8
print tmsum(T, X, window=3)
// output
[1, 3, 6, 4, 9, 15, 13, 15]