exponential_moving_average¶
-
exponential_moving_average
(x, alpha=0.75)[source]¶ Exponentially weighted moving average time series from previous values.
- Parameters
x (
Series
) – time series of pricesalpha (
float
) – how much to weigh the previous price in the time series, thus controlling how much importance we place on the (more distant) past
- Return type
Series
- Returns
date-based time series of return
Usage
An exponential(ly weighted) moving average (EMA), is defined as:
\(R_{t+1} = \alpha \cdot R_t + (1 - \alpha) \cdot P_t\)
where :math: alpha is the weight we place on the previous day’s 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()
:func:’moving_average’ :func:’smoothed_moving_average’