moving#

swordfish.function.moving()#

Apply the function/operator to a moving window of the given objects.

The moving template always returns a vector with the same number of elements as the number of rows in the input arguments. It starts calculating when the moving window size is reached for the first time, and the moving window is always shifted by 1 element to the right thereafter.

Each of the built-in moving functions such as msum, mcount and mavg is optimized for its specific task. Therefore, they have much better performance than the moving template.

Parameters:
  • func (Constant) –

    An aggregate function.

    Note

    When using this parameter, the keyword used to define the corresponding aggregation function is defg. For details, refer to Tutorial: User Defined Aggregate Functions.

  • funcArgs (Constant) – The parameters of func. They can be vectors/dictionaries/tables/matrices. It is a tuple if there are more than one parameter of func, and all parameters must have the same size.

  • window (Constant) – The moving window size.

  • minPeriods (Constant) – A positive integer indicating the minimum number of observations in a window in order to generate a result. The default value is the value of window.