Logo

Coding preview

Weighted Moving Average

What this preview is

About this preview

Weighted Moving Average is a easy quant coding problem on language knowledge in Python, asked at Quant.

Unlock full access to getcracked

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

Implementing a weighted moving average in Python

This is an easy coding problem that tests your ability to implement a core quantitative finance calculation cleanly. Weighted moving averages are used constantly in signal generation and trend filtering, so firms like quant trading desks expect candidates to code this accurately and efficiently on first attempt.

The problem rewards careful index handling and correct application of the weight formula. You need to iterate over valid window positions, compute the linearly-weighted sum of prices in each window, normalize by the sum of weights, and format the output properly. Edge cases (window too large, invalid sizes) should be handled explicitly.

  • Sliding window iteration and boundary conditions
  • Arithmetic series and weight normalization
  • List comprehension and rounding to specification