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