Rolling VWAP over a Time Window

Asked at DRW · Coding Questions · Difficulty: Medium · Last asked Nov 23, 2026

A trading system receives a stream of trades, each with a symbol, a price, a quantity and a timestamp. Traders want the volume-weighted average price (VWAP) of one symbol over the most recent stretch of time: the average trade price where each trade counts in proportion to its quantity. Build a class that records trades as they arrive and answers this question for any symbol at any moment.

Loading the problem…