Super Smoother¶
SuperSmoother algorithm for time series smoothing.
Implementation based on John Ehlers' SuperSmoother filter, which is a two-pole Butterworth filter that provides excellent smoothing while minimizing lag. The filter uses an adaptive approach with cross-validation to determine the optimal smoothing parameters.
Reference: Ehlers, J. (2013). "Cycle Analytics for Traders"
quantflow.ta.SuperSmoother
pydantic-model
¶
Bases: BaseModel
SuperSmoother filter for time series data.
This implementation uses a two-pole Butterworth filter with adaptive smoothing. The SuperSmoother filter is designed to remove high-frequency noise while preserving the underlying trend with minimal lag. The filter is defined by the following recurrence relation:
where the coefficients are calculated as:
and \(N\) is the period.
Example¶
import pandas as pd
smoother = SuperSmoother(period=10)
df = pd.DataFrame({"value": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]})
df["smoothed"] = df["value"].apply(smoother.update)
For online updates:
smoother = SuperSmoother(period=10)
for value in [1, 2, 3, 4, 5]:
smoothed = smoother(value)
print(smoothed)
Fields:
-
period(int)
raw_value
¶
value
¶
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:
|