One Euro Filter
All functions · nseries package
OneEuroFilter
func (s Series) OneEuroFilter(periodMin float64, beta float64) Series
OneEuroFilter applies an adaptive low-pass filter modelled on the 1-Euro filter, as translated from the TradeStation (EasyLanguage) implementation. The rate of change of the input is exponentially smoothed and used to adapt the cutoff period: cutoff = periodMin + beta*|smoothed dx|. The periodMin parameter sets the minimum cutoff period and beta controls the speed adaptation.
Note that this adaptation works in the period domain, so a larger beta increases smoothing during fast movements. This is the behaviour of the TradeStation original that this implementation is verified against, but it is the opposite of Casiez’s published 1-Euro filter, which raises the cutoff frequency (reducing smoothing and lag) as speed increases.
periodMin is in bars; beta multiplies the smoothed one-bar change in price units, so its effect depends on the price scale, and a beta tuned on a 10-dollar stock is 10 times too weak on a 100-dollar stock. Bar 0 is s[0], and the smoothed change starts at 0.