macrosynergy.management.utils.math#

Contains mathematical utility functions used across the package.

expanding_mean_with_nan(dfw, absolute=False)[source]#

Computes a rolling median of a vector of floats and returns the results. NaNs will be consumed.

Parameters:
  • dfw (DataFrame) – “wide” dataframe with time index and cross-sections as columns.

  • absolute (bool) – if True, the rolling mean will be computed on the magnitude of each value. Default is False.

Return <List[float] ret:

a list containing the median values. The number of computed median values held inside the list will correspond to the number of timestamps the series is defined over.

Return type:

List[float64]