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:
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.