gs_quant.timeseries.technicals.exponential_moving_average

exponential_moving_average(x, beta=0.75)[source]

Exponentially weighted moving average

Parameters:
  • x (Series) – time series of prices

  • beta (float) – how much to weigh the previous observations in the time series, thus controlling how much importance we place on the (more distant) past. Must be between 0 (inclusive) and 1 (exclusive)

Return type:

Series

Returns:

date-based time series of return

Usage

The exponential(ly weighted) moving average (EMA) of a series [\(X_0\), \(X_1\), \(X_2\), …], is defined as:

\(Y_0 = X_0\)

\(Y_t = \beta \cdot Y_{t-1} + (1 - \beta) \cdot X_t\)

where \(\beta\) is the weight we place on the previous average.

See Exponential moving average for more information

Examples

Generate price series with 100 observations starting from today’s date:

>>> prices = generate_series(100)
>>> exponential_moving_average(prices, 0.9)

See also

mean() moving_average() smoothed_moving_average()