About this question

Hodrick-Prescott Trend-Cycle Decomposition

Medium · time_series · Quant Researcher interview question · hp-filter, trend-decomposition, time-series, macro, linear-algebra

The Hodrick-Prescott (HP) filter decomposes a time series into a smooth trend and a stationary cycle by solving a penalized least-squares problem. In quantitative finance, it is a standard de-trending step for constructing momentum signals and developing regime-detection algorithms. The filter's smoothness is controlled by a parameter lam, which is set according to the data's frequency. Task Implement the function solution(series: list, lam: float) -> list to apply the Hodrick-Prescott filter t