We just released our Beginner Hardware Design roadmap. We're leaning into HWE interview preparation. The price will rise as the content expands.

Logo

Keep it moving (averages)

What this preview is

Keep it moving (averages) is a cooked quant coding problem on language knowledge in Cpp / Python.

Difficulty
Cooked
Topic
Language Knowledge
Discipline
Quant development
Languages
Cpp / Python

Implementing exponentially weighted moving averages in C++ and Python

This is a straightforward coding problem that tests your ability to translate a recurrence relation into clean, efficient code. It appears frequently in quantitative finance interviews because EWMA is a fundamental technique for smoothing noisy time-series data—particularly returns and volatility estimates.

The problem gives you an explicit formula: at each step, blend the current observation with the previous average using a fixed decay parameter (alpha). The key is to iterate through the series up to the terminal day, applying the update rule correctly at each step. Since you only need the previous EWMA value to compute the next one, a single-pass loop with O(1) space is both natural and required. Pay attention to the boundary condition (day 1) and ensure your arithmetic handles floating-point precision appropriately.

  • Iterative accumulation and state management
  • Off-by-one errors in 1-indexed time series
  • Floating-point accuracy in financial calculations

Unlock full access to getcracked

Join to unlock this problem, detailed solutions, and our complete library of quant finance interview prep.