Quant Memo
Coding/●●●●●

Per-symbol VWAP from a mixed tape

Asked at Millennium

You receive a consolidated tape as (timestamp, symbol, price, size) tuples covering many tickers interleaved. For each symbol compute its full-day VWAP:

VWAPs=ipiqiiqi\text{VWAP}_s = \frac{\sum_i p_i q_i}{\sum_i q_i}

trades = [(1, "AAPL", 100.0, 10), (1, "MSFT", 200.0, 5), (2, "AAPL", 102.0, 30)]
-> {"AAPL": 101.5, "MSFT": 200.0}     # (100*10 + 102*30) / 40 = 101.5

Return a dict mapping symbol to VWAP, in one pass over the tape.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions