EWMA¶
quantflow.ta.EWMA
pydantic-model
¶
Bases: BaseModel
Exponentially Weighted Moving Average filter for time series data.
This implementation uses the standard EWMA formula:
where \(\alpha\) is the smoothing factor derived from the period parameter. To match SuperSmoother characteristics, the formula is:
This provides frequency response similar to a simple moving average and approximates the smoothing characteristics of higher-order filters.
Example¶
import pandas as pd
ewma = EWMA(period=10)
df = pd.DataFrame({"value": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]})
df["ewma"] = df["value"].apply(ewma.update)
For online updates:
Fields:
from_half_life
classmethod
¶
Create an EWMA using half-life semantics instead of period.
The half-life represents the time for weight to decay to 0.5.
Source code in quantflow/ta/ewma.py
update
¶
Update the filter with a new value and return the smoothed result.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
New data point to add to the filter
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
Smoothed value using the EWMA algorithm |